[ruby-postgres/f14/master] Update ruby-postgres to 0.7.9-2008.01.28

Chris Lalancette clalance at fedoraproject.org
Wed Sep 8 17:38:32 UTC 2010


commit 488da388b4f1aec03be6af1ed87d7b8aa5ef69e9
Author: Chris Lalancette <clalance at redhat.com>
Date:   Wed Sep 8 13:35:26 2010 -0400

    Update ruby-postgres to 0.7.9-2008.01.28
    
    Signed-off-by: Chris Lalancette <clalance at redhat.com>

 .gitignore                    |    1 +
 0001-Implement-trace.patch    |  107 +++++++++++++++++++++++++++++++++++++++++
 0002-Implement-notifies.patch |   44 +++++++++++++++++
 0003-Implement-print.patch    |  100 ++++++++++++++++++++++++++++++++++++++
 cflags.patch                  |   10 ----
 ruby-postgres.spec            |   26 ++++++++--
 sources                       |    2 +-
 7 files changed, 273 insertions(+), 17 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 61c4611..5914422 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 ruby-postgres-0.7.1.tar.gz
+/ruby-postgres-0.7.9.2008.01.28.tar.gz
diff --git a/0001-Implement-trace.patch b/0001-Implement-trace.patch
new file mode 100644
index 0000000..ef1aff3
--- /dev/null
+++ b/0001-Implement-trace.patch
@@ -0,0 +1,107 @@
+From 6c2d7f91f421e926f2588fcd24857b58265b5133 Mon Sep 17 00:00:00 2001
+From: Chris Lalancette <clalance at redhat.com>
+Date: Tue, 7 Sep 2010 16:13:34 -0400
+Subject: [PATCH] Implement trace.
+
+This is a backport of the upstream ruby-pg changesets 56, 57, and 59.
+
+Signed-off-by: Chris Lalancette <clalance at redhat.com>
+---
+ ext/postgres.c |   64 +++++++++++++++++++++++++++++++++++++++----------------
+ 1 files changed, 45 insertions(+), 19 deletions(-)
+
+diff --git a/ext/postgres.c b/ext/postgres.c
+index c6c2bb7..e9bb032 100644
+--- a/ext/postgres.c
++++ b/ext/postgres.c
+@@ -33,6 +33,7 @@
+ #include <libpq/libpq-fs.h>              /* large-object interface */
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <unistd.h>
+ #include <sys/types.h>
+ 
+ #ifndef HAVE_PQSERVERVERSION
+@@ -1212,26 +1213,48 @@ pgconn_error(obj)
+     return rb_tainted_str_new2(error);
+ }
+ 
+-/*TODO broken for ruby 1.9
++/*
+  * call-seq:
+- *    conn.trace( port )
++ *    conn.trace( stream )
+  * 
+- * Enables tracing message passing between backend.
+- * The trace message will be written to the _port_ object,
+- * which is an instance of the class +File+.
++ * Enables tracing message passing between backend. The
++ * trace message will be written to the stream _stream_,
++ * which must implement a method +fileno+ that returns
++ * a writable file descriptor.
+  */
+ static VALUE
+-pgconn_trace(obj, port)
+-    VALUE obj, port;
++pgconn_trace(VALUE self, VALUE stream)
+ {
+-    //OpenFile* fp;
++	VALUE fileno;
++	FILE *new_fp;
++	int old_fd, new_fd;
++	VALUE new_file;
+ 
+-    Check_Type(port, T_FILE);
+-    //GetOpenFile(port, fp);
++	if(rb_respond_to(stream,rb_intern("fileno")) == Qfalse)
++		rb_raise(rb_eArgError, "stream does not respond to method: fileno");
+ 
+-    //PQtrace(get_pgconn(obj), fp->f2?fp->f2:fp->f);
++	fileno = rb_funcall(stream, rb_intern("fileno"), 0);
++	if(fileno == Qnil)
++		rb_raise(rb_eArgError, "can't get file descriptor from stream");
+ 
+-    return obj;
++	/* Duplicate the file descriptor and re-open
++	 * it. Then, make it into a ruby File object
++	 * and assign it to an instance variable.
++	 * This prevents a problem when the File
++	 * object passed to this function is closed
++	 * before the connection object is. */
++	old_fd = NUM2INT(fileno);
++	new_fd = dup(old_fd);
++	new_fp = fdopen(new_fd, "w");
++
++	if(new_fp == NULL)
++		rb_raise(rb_eArgError, "stream is not writable");
++
++	new_file = rb_funcall(rb_cIO, rb_intern("new"), 1, INT2NUM(new_fd));
++	rb_iv_set(self, "@trace_file", new_file);
++
++	PQtrace(get_pgconn(self), new_fp);
++	return self;
+ }
+ 
+ /*
+@@ -1241,11 +1264,14 @@ pgconn_trace(obj, port)
+  * Disables the message tracing.
+  */
+ static VALUE
+-pgconn_untrace(obj)
+-    VALUE obj;
++pgconn_untrace(VALUE self)
+ {
+-    PQuntrace(get_pgconn(obj));
+-    return obj;
++	VALUE trace_stream;
++	PQuntrace(get_pgconn(self));
++	trace_stream = rb_iv_get(self, "@trace_stream");
++	rb_funcall(trace_stream, rb_intern("close"), 0);
++	rb_iv_set(self, "@trace_stream", Qnil);
++	return self;
+ }
+ 
+ /*
+-- 
+1.7.2.2
+
diff --git a/0002-Implement-notifies.patch b/0002-Implement-notifies.patch
new file mode 100644
index 0000000..c3e427b
--- /dev/null
+++ b/0002-Implement-notifies.patch
@@ -0,0 +1,44 @@
+From be2909dbf96f7bdb18ba97d8f32639a787b0cfa9 Mon Sep 17 00:00:00 2001
+From: Chris Lalancette <clalance at redhat.com>
+Date: Tue, 7 Sep 2010 16:13:48 -0400
+Subject: [PATCH] Implement notifies.
+
+This no longer exists in the upstream ruby-pg project, but this
+source is pulled from the older 0.7.1 project to retain
+compatibility.
+
+Signed-off-by: Chris Lalancette <clalance at redhat.com>
+---
+ ext/postgres.c |    9 +++++++++
+ 1 files changed, 9 insertions(+), 0 deletions(-)
+
+diff --git a/ext/postgres.c b/ext/postgres.c
+index e9bb032..d3a04bf 100644
+--- a/ext/postgres.c
++++ b/ext/postgres.c
+@@ -1060,6 +1060,14 @@ pgconn_endcopy(obj)
+     return Qnil;
+ }
+ 
++static VALUE
++pgconn_notifies(obj)
++    VALUE obj;
++{
++    PQnotifies(get_pgconn(obj));
++    return Qnil;
++}
++
+ static void
+ notice_proxy(self, message)
+     VALUE self;
+@@ -2697,6 +2705,7 @@ Init_postgres()
+     rb_define_method(rb_cPGconn, "putline", pgconn_putline, 1);
+     rb_define_method(rb_cPGconn, "getline", pgconn_getline, 0);
+     rb_define_method(rb_cPGconn, "endcopy", pgconn_endcopy, 0);
++    rb_define_method(rb_cPGconn, "notifies", pgconn_notifies, 0);
+     rb_define_method(rb_cPGconn, "on_notice", pgconn_on_notice, 0);
+     rb_define_method(rb_cPGconn, "transaction_status", pgconn_transaction_status, 0);
+     rb_define_method(rb_cPGconn, "protocol_version", pgconn_protocol_version, 0);
+-- 
+1.7.2.2
+
diff --git a/0003-Implement-print.patch b/0003-Implement-print.patch
new file mode 100644
index 0000000..0e87861
--- /dev/null
+++ b/0003-Implement-print.patch
@@ -0,0 +1,100 @@
+From 45f28a97d00c4cf2b73dd877b6a7499eec3bc035 Mon Sep 17 00:00:00 2001
+From: Chris Lalancette <clalance at redhat.com>
+Date: Tue, 7 Sep 2010 16:14:07 -0400
+Subject: [PATCH] Implement print.
+
+This no longer exists in the upstream ruby-pg project, but this
+source is pulled from the older 0.7.1 project to retain
+compatibility.
+
+Signed-off-by: Chris Lalancette <clalance at redhat.com>
+---
+ ext/postgres.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 files changed, 65 insertions(+), 0 deletions(-)
+
+diff --git a/ext/postgres.c b/ext/postgres.c
+index d3a04bf..8d8083d 100644
+--- a/ext/postgres.c
++++ b/ext/postgres.c
+@@ -1924,6 +1924,70 @@ pgresult_getisnull(obj, tup_num, field_num)
+     return PQgetisnull(result, i, j) ? Qtrue : Qfalse;
+ }
+ 
++static VALUE
++pgresult_print(obj, file, opt)
++    VALUE obj, file, opt;
++{
++    VALUE value;
++    ID mem;
++    OpenFile* fp;
++    PQprintOpt po;
++
++    Check_Type(file, T_FILE);
++    Check_Type(opt,  T_STRUCT);
++    GetOpenFile(file, fp);
++
++    memset(&po, 0, sizeof(po));
++
++    mem = rb_intern("header");
++    value = rb_struct_getmember(opt, mem);
++    po.header = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("align");
++    value = rb_struct_getmember(opt, mem);
++    po.align = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("standard");
++    value = rb_struct_getmember(opt, mem);
++    po.standard = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("html3");
++    value = rb_struct_getmember(opt, mem);
++    po.html3 = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("expanded");
++    value = rb_struct_getmember(opt, mem);
++    po.expanded = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("pager");
++    value = rb_struct_getmember(opt, mem);
++    po.pager = value == Qtrue ? 1 : 0;
++
++    mem = rb_intern("fieldSep");
++    value = rb_struct_getmember(opt, mem);
++    if (!NIL_P(value)) {
++      Check_Type(value, T_STRING);
++      po.fieldSep = STR2CSTR(value);
++    }
++
++    mem = rb_intern("tableOpt");
++    value = rb_struct_getmember(opt, mem);
++    if (!NIL_P(value)) {
++      Check_Type(value, T_STRING);
++      po.tableOpt = STR2CSTR(value);
++    }
++
++    mem = rb_intern("caption");
++    value = rb_struct_getmember(opt, mem);
++    if (!NIL_P(value)) {
++      Check_Type(value, T_STRING);
++      po.caption = STR2CSTR(value);
++    }
++
++    PQprint(fp->f2?fp->f2:fp->f, get_pgresult(obj), &po);
++    return obj;
++}
++
+ /*
+  * call-seq:
+  *    res.cmdtuples()
+@@ -2791,6 +2855,7 @@ Init_postgres()
+ 	rb_define_alias(rb_cPGresult, "cmdtuples", "cmd_tuples");
+     rb_define_method(rb_cPGresult, "cmdstatus", pgresult_cmdstatus, 0);
+     rb_define_method(rb_cPGresult, "oid", pgresult_oid, 0);
++    rb_define_method(rb_cPGresult, "print", pgresult_print, 2);
+     rb_define_method(rb_cPGresult, "clear", pgresult_clear, 0);
+     rb_define_alias(rb_cPGresult, "close", "clear");
+ 
+-- 
+1.7.2.2
+
diff --git a/ruby-postgres.spec b/ruby-postgres.spec
index 618dbd5..9d2dfa6 100644
--- a/ruby-postgres.spec
+++ b/ruby-postgres.spec
@@ -1,17 +1,19 @@
 %{!?ruby_sitearch: %define ruby_sitearch %(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")}
 
 Name: ruby-postgres
-Version: 0.7.1
-Release: 12%{?dist}
+Version: 0.7.9
+Release: 2008.01.28.2%{?dist}
 Summary: A Ruby interface for the PostgreSQL database engine
 Group: Development/Languages
 # Source says that ruby-gems-postgres is distributable under the same
 # terms as ruby.
 License: Ruby
-URL: http://ruby.scripting.ca/postgres/
-Source: http://ruby.scripting.ca/postgres/archive/ruby-postgres-0.7.1.tar.gz
-Patch0: cflags.patch
+URL: http://bitbucket.org/ged/ruby-pg/
+Source: http://bitbucket.org/ged/ruby-pg/downloads/%{name}-%{version}.2008.01.28.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
+Patch1: 0001-Implement-trace.patch
+Patch2: 0002-Implement-notifies.patch
+Patch3: 0003-Implement-print.patch
 
 Requires: ruby >= 1.3
 Requires: ruby(abi) = 1.8
@@ -27,14 +29,18 @@ Database driver to access PostgreSQL databases from Ruby.
 
 %prep
 %setup -q
-%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
 chmod a-x sample/psql.rb
 
 %build
+cd ext
 ruby extconf.rb --with-cflags="$RPM_OPT_FLAGS"
 make
 
 %install
+cd ext
 rm -rf $RPM_BUILD_ROOT
 make DESTDIR=%{buildroot} install
 
@@ -47,6 +53,14 @@ rm -rf %{buildroot}
 %{ruby_sitearch}/postgres.so
 
 %changelog
+* Wed Sep 08 2010 Chris Lalancette <clalance at redhat.com> - 0.7.9.2008.01.28.2
+- Add patch to implement trace support (from upstream ruby-pg project)
+- Add patch to implement print support (from older 0.7.1 sources)
+- Add patch to implement notifies call (from older 0.7.1 sources)
+
+* Fri Aug 13 2010 Chris Lalancette <clalance at redhat.com> - 0.7.9.2008.01.28.1
+- Update to ruby-postgres .7.9.2008.01.28
+
 * Sun Jul 26 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.7.1-12
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
 
diff --git a/sources b/sources
index accc9a9..7dfa78c 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-8ef67b3f4b089248f0420baeb0e3b3c8  ruby-postgres-0.7.1.tar.gz
+af48fb33beaecf773ebca45c0a64a15d  ruby-postgres-0.7.9.2008.01.28.tar.gz


More information about the scm-commits mailing list