Hello community,
here is the log from the commit of package rubygem-pg for openSUSE:Factory checked in at 2015-05-16 07:14:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-pg (Old)
and /work/SRC/openSUSE:Factory/.rubygem-pg.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-pg"
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-pg/rubygem-pg.changes 2015-02-10 20:21:51.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.rubygem-pg.new/rubygem-pg.changes 2015-05-16 07:14:20.000000000 +0200
@@ -1,0 +2,173 @@
+Fri May 15 04:31:04 UTC 2015 - coolo@suse.com
+
+- updated to version 0.18.2
+ see installed ChangeLog
+
+ 2015-05-14 Michael Granger
+
+ * .rvmrc:
+ Bump default rvm Ruby to 2.2
+ [128b075d5800] [tip]
+
+ 2015-03-13 Lars Kanis
+
+ * ext/pg_text_encoder.c, ext/util.c, ext/util.h:
+ Avoid possible symbol name clash when linking againt static libpq.
+
+ This should fix issue #209 .
+ [b859963462b2]
+
+ 2015-02-11 Lars Kanis
+
+ * ext/pg.c, spec/pg/connection_spec.rb:
+ Merge from git branch.
+ [b60c89ee93c8]
+
+ * ext/pg.h, ext/pg_text_decoder.c:
+ Merge branch 'non-c99-compiler'
+ [b111c84b8445]
+
+ 2015-02-06 Lars Kanis
+
+ * ext/extconf.rb, ext/pg.h, ext/pg_result.c, ext/pg_text_decoder.c,
+ ext/pg_type_map_by_mri_type.c:
+ Use fixed size arrays in case the compiler doesn't support C99
+ variable length arrays.
+
+ This is notably the MSVC compiler.
+
+ Note: The MSVC build environment is currently not tested on a
+ regular base, so is not fully supported.
+ [1269b8ad77b8]
+
+ 2015-02-11 Lars Kanis
+
+ * ext/pg_connection.c:
+ Replace quote_ident implementation with that of
+ PG::TextEncoder::Identifier .
+
+ This allowes quoation of array of strings in addition to plain
+ strings and removes duplicated code.
+
+ It also removes the 63 byte limitation and therefore obsolets pull
+ request #21 https://bitbucket.org/ged/ruby-pg/pull-request/21
+ [714601d05fba]
+
+ * ext/pg.c, ext/pg.h, ext/pg_text_decoder.c, ext/pg_text_encoder.c,
+ spec/pg/connection_spec.rb, spec/pg/type_spec.rb:
+ Derive PG::TextDecoder::Identifier from PG::SimpleDecoder instead of
+ CompositeDecoder
+
+ .. and equally for Encoder.
+
+ Identifiers are strings, so there is no good reason to compose it
+ from other element types. This change allows a faster quoting
+ implementation.
+ [df67241d1a4f]
+
+ 2015-02-03 Michael Granger
+
+ * README.rdoc, ext/pg.c:
+ Update copyright notices
+ [447962e0dcba] [github/master]
+
+ * spec/pg/connection_spec.rb:
+ Whitespace fixes
+ [f4a85f78807d]
+
+ 2014-08-22 Chris Bandy
+
+ * lib/pg/connection.rb, spec/pg/connection_spec.rb:
+ Allow URI connection string
+
+ (Imported from https://github.com/ged/ruby-pg/pull/3)
+ [d4579ef9eae4]
+
+ 2015-01-27 Lars Kanis
+
+ * lib/pg/text_decoder.rb, spec/pg/type_spec.rb:
+ Fix decoding of fractional timezones like "-00:25:21".
+ [766aa353b392]
+
+ 2015-01-27 Lars Kanis
+
+ * History.rdoc, lib/pg/text_decoder.rb, spec/pg/type_spec.rb:
+ Fix decoding of fractional timezones like "04:30".
+
+ This fixes https://bitbucket.org/ged/ruby-pg/issue/203 .
+ [33225805259c]
+
+ 2015-01-16 Lars Kanis
+
+ * History.rdoc, ext/extconf.rb, ext/pg_connection.c,
+ spec/pg/connection_spec.rb:
+ Revert "Add PG::Connection#hostaddr. This is new in PostgreSQL-9.4."
+
+ PQhostaddr was removed from final PostgreSQL-9.4.0.
+
+ This fixes issue #202 :https://bitbucket.org/ged/ruby-pg/issue/202
+
+ This reverts commit 03deab7aa63f9a00984014ce59617d552b4eac34.
+ [b51d736bca77]
+
+ * History.rdoc:
+ Add a missing enhancement for pg-0.18.0
+ [a7635c3425f3]
+
+ * .travis.yml:
+ Update ruby and postgresql versions for travic-ci
+ [b67b92f7db97]
+
+ 2015-01-06 Lars Kanis
+
+ * Merge from git.
+ [625e9359ac47]
+
+ 2015-01-05 Lars Kanis
+
+ * ext/pg_type_map_in_ruby.c:
+ Use a simpler fix for https://bitbucket.org/ged/ruby-
+ pg/commits/a38cf53a96f
+ [3d89d3aae4fd]
+
+ 2015-01-05 Michael Granger
+
+ * .hgtags:
+ Added tag v0.18.1 for changeset f97dd6cb4f34
+ [f8122014065a]
+
+ * .hgsigs:
+ Added signature for changeset ba5aff64b5cb
+ [f97dd6cb4f34] [v0.18.1]
+
+ * History.rdoc, lib/pg.rb:
+ Bump the patch version, update history
+ [ba5aff64b5cb]
+
+ * Rakefile:
+ Fix the minimum Ruby version (closes #199)
+ [69422cc8dc45]
+
+ 2015-01-03 Michael Granger
+
+ * .hgtags:
+ Added tag v0.18.0 for changeset cfb2bfc0f661
+ [8aff3973f2d2]
+
+ * .hgsigs:
+ Added signature for changeset c519766e3ec9
+ [cfb2bfc0f661] [v0.18.0]
+
+ * History.rdoc:
+ Update the History
+ [c519766e3ec9]
+
+ * Manifest.txt:
+ Keep the manifest sorted so it can be diffed.
+ [d7cdbfd1b516]
+
+ * Rakefile:
+ Add a Rake task for generating the gemspec
+ [ec6d6ce61a15]
+
+-------------------------------------------------------------------
Old:
----
pg-0.18.1.gem
New:
----
pg-0.18.2.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-pg.spec ++++++
--- /var/tmp/diff_new_pack.28qWmT/_old 2015-05-16 07:14:21.000000000 +0200
+++ /var/tmp/diff_new_pack.28qWmT/_new 2015-05-16 07:14:21.000000000 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-pg
-Version: 0.18.1
+Version: 0.18.2
Release: 0
%define mod_name pg
%define mod_full_name %{mod_name}-%{version}
++++++ pg-0.18.1.gem -> pg-0.18.2.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ChangeLog new/ChangeLog
--- old/ChangeLog 2015-01-05 21:59:11.000000000 +0100
+++ new/ChangeLog 2015-05-14 20:50:00.000000000 +0200
@@ -1,9 +1,176 @@
+2015-05-14 Michael Granger
+
+ * .rvmrc:
+ Bump default rvm Ruby to 2.2
+ [128b075d5800] [tip]
+
+2015-03-13 Lars Kanis
+
+ * ext/pg_text_encoder.c, ext/util.c, ext/util.h:
+ Avoid possible symbol name clash when linking againt static libpq.
+
+ This should fix issue #209 .
+ [b859963462b2]
+
+2015-02-11 Lars Kanis
+
+ * ext/pg.c, spec/pg/connection_spec.rb:
+ Merge from git branch.
+ [b60c89ee93c8]
+
+ * ext/pg.h, ext/pg_text_decoder.c:
+ Merge branch 'non-c99-compiler'
+ [b111c84b8445]
+
+2015-02-06 Lars Kanis
+
+ * ext/extconf.rb, ext/pg.h, ext/pg_result.c, ext/pg_text_decoder.c,
+ ext/pg_type_map_by_mri_type.c:
+ Use fixed size arrays in case the compiler doesn't support C99
+ variable length arrays.
+
+ This is notably the MSVC compiler.
+
+ Note: The MSVC build environment is currently not tested on a
+ regular base, so is not fully supported.
+ [1269b8ad77b8]
+
+2015-02-11 Lars Kanis
+
+ * ext/pg_connection.c:
+ Replace quote_ident implementation with that of
+ PG::TextEncoder::Identifier .
+
+ This allowes quoation of array of strings in addition to plain
+ strings and removes duplicated code.
+
+ It also removes the 63 byte limitation and therefore obsolets pull
+ request #21 https://bitbucket.org/ged/ruby-pg/pull-request/21
+ [714601d05fba]
+
+ * ext/pg.c, ext/pg.h, ext/pg_text_decoder.c, ext/pg_text_encoder.c,
+ spec/pg/connection_spec.rb, spec/pg/type_spec.rb:
+ Derive PG::TextDecoder::Identifier from PG::SimpleDecoder instead of
+ CompositeDecoder
+
+ .. and equally for Encoder.
+
+ Identifiers are strings, so there is no good reason to compose it
+ from other element types. This change allows a faster quoting
+ implementation.
+ [df67241d1a4f]
+
+2015-02-03 Michael Granger
+
+ * README.rdoc, ext/pg.c:
+ Update copyright notices
+ [447962e0dcba] [github/master]
+
+ * spec/pg/connection_spec.rb:
+ Whitespace fixes
+ [f4a85f78807d]
+
+2014-08-22 Chris Bandy
+
+ * lib/pg/connection.rb, spec/pg/connection_spec.rb:
+ Allow URI connection string
+
+ (Imported from https://github.com/ged/ruby-pg/pull/3)
+ [d4579ef9eae4]
+
+2015-01-27 Lars Kanis
+
+ * lib/pg/text_decoder.rb, spec/pg/type_spec.rb:
+ Fix decoding of fractional timezones like "-00:25:21".
+ [766aa353b392]
+
+2015-01-27 Lars Kanis
+
+ * History.rdoc, lib/pg/text_decoder.rb, spec/pg/type_spec.rb:
+ Fix decoding of fractional timezones like "04:30".
+
+ This fixes https://bitbucket.org/ged/ruby-pg/issue/203 .
+ [33225805259c]
+
+2015-01-16 Lars Kanis
+
+ * History.rdoc, ext/extconf.rb, ext/pg_connection.c,
+ spec/pg/connection_spec.rb:
+ Revert "Add PG::Connection#hostaddr. This is new in PostgreSQL-9.4."
+
+ PQhostaddr was removed from final PostgreSQL-9.4.0.
+
+ This fixes issue #202 :https://bitbucket.org/ged/ruby-pg/issue/202
+
+ This reverts commit 03deab7aa63f9a00984014ce59617d552b4eac34.
+ [b51d736bca77]
+
+ * History.rdoc:
+ Add a missing enhancement for pg-0.18.0
+ [a7635c3425f3]
+
+ * .travis.yml:
+ Update ruby and postgresql versions for travic-ci
+ [b67b92f7db97]
+
+2015-01-06 Lars Kanis
+
+ * Merge from git.
+ [625e9359ac47]
+
+2015-01-05 Lars Kanis
+
+ * ext/pg_type_map_in_ruby.c:
+ Use a simpler fix for https://bitbucket.org/ged/ruby-
+ pg/commits/a38cf53a96f
+ [3d89d3aae4fd]
+
+2015-01-05 Michael Granger
+
+ * .hgtags:
+ Added tag v0.18.1 for changeset f97dd6cb4f34
+ [f8122014065a]
+
+ * .hgsigs:
+ Added signature for changeset ba5aff64b5cb
+ [f97dd6cb4f34] [v0.18.1]
+
+ * History.rdoc, lib/pg.rb:
+ Bump the patch version, update history
+ [ba5aff64b5cb]
+
+ * Rakefile:
+ Fix the minimum Ruby version (closes #199)
+ [69422cc8dc45]
+
+2015-01-03 Michael Granger
+
+ * .hgtags:
+ Added tag v0.18.0 for changeset cfb2bfc0f661
+ [8aff3973f2d2]
+
+ * .hgsigs:
+ Added signature for changeset c519766e3ec9
+ [cfb2bfc0f661] [v0.18.0]
+
+ * History.rdoc:
+ Update the History
+ [c519766e3ec9]
+
+ * Manifest.txt:
+ Keep the manifest sorted so it can be diffed.
+ [d7cdbfd1b516]
+
+ * Rakefile:
+ Add a Rake task for generating the gemspec
+ [ec6d6ce61a15]
+
2014-12-26 Lars Kanis
* lib/pg/basic_type_mapping.rb:
Add a warning about Type OIDs without decoder in
PG::BasicTypeMapForResults.
- [592e29cdf2e9] [tip]
+ [592e29cdf2e9]
2014-12-13 Lars Kanis
@@ -285,7 +452,7 @@
* ext/pg_text_encoder.c, spec/pg/type_spec.rb:
Allow non Array values as input for TextEncoder::Array.
- [a4725dfca9e4] [github/master]
+ [a4725dfca9e4]
* ext/pg_coder.c, spec/pg/type_spec.rb:
Clarify handling of nil/NULL values by PG::Coders.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.rdoc new/History.rdoc
--- old/History.rdoc 2015-01-05 21:59:11.000000000 +0100
+++ new/History.rdoc 2015-05-14 20:50:00.000000000 +0200
@@ -1,3 +1,18 @@
+== v0.18.2 [2015-05-14] Michael Granger
+
+Enhancements:
+
+- Allow URI connection string (thanks to Chris Bandy)
+
+Bugfixes:
+
+- Speedups and fixes for PG::TextDecoder::Identifier and quoting behavior
+- Revert addition of PG::Connection#hostaddr [#202].
+- Fix decoding of fractional timezones and timestamps [#203]
+- Fixes for non-C99 compilers
+- Avoid possible symbol name clash when linking againt static libpq.
+
+
== v0.18.1 [2015-01-05] Michael Granger
Correct the minimum compatible Ruby version to 1.9.3. #199
@@ -19,6 +34,7 @@
- Add Enumerator variant to PG::Result#each and #each_row.
- Add PG::Connection#conninfo and #hostaddr.
- Add PG.init_openssl and PG.init_ssl methods.
+- Add PG::Result.inspect
- Force zero termination for all text strings that are given to libpq.
It raises an ArgumentError if the string contains a null byte.
- Update Windows cross build to PostgreSQL 9.3.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.rdoc new/README.rdoc
--- old/README.rdoc 2015-01-05 21:59:11.000000000 +0100
+++ new/README.rdoc 2015-05-14 20:50:00.000000000 +0200
@@ -130,7 +130,7 @@
== Copying
-Copyright (c) 1997-2013 by the authors.
+Copyright (c) 1997-2015 by the authors.
* Jeff Davis
* Guy Decoux (ts)
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
Files old/checksums.yaml.gz.sig and new/checksums.yaml.gz.sig differ
Files old/data.tar.gz.sig and new/data.tar.gz.sig differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/extconf.rb new/ext/extconf.rb
--- old/ext/extconf.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/extconf.rb 2015-05-14 20:50:00.000000000 +0200
@@ -73,7 +73,6 @@
have_func 'PQping'
have_func 'PQsetSingleRowMode'
have_func 'PQconninfo'
-have_func 'PQhostaddr'
have_func 'rb_encdb_alias'
have_func 'rb_enc_alias'
@@ -95,6 +94,10 @@
have_header 'unistd.h'
have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
+checking_for "C99 variable length arrays" do
+ $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
+end
+
create_header()
create_makefile( "pg_ext" )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg.c new/ext/pg.c
--- old/ext/pg.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg.c - Toplevel extension
- * $Id: pg.c,v a9724aef9116 2014/12/12 21:03:27 lars $
+ * $Id: pg.c,v b60c89ee93c8 2015/02/11 20:59:36 lars $
*
* Author/s:
*
@@ -15,7 +15,7 @@
* See Contributors.rdoc for the many additional fine people that have contributed
* to this library over the years.
*
- * Copyright (c) 1997-2012 by the authors.
+ * Copyright (c) 1997-2015 by the authors.
*
* You may redistribute this software under the same terms as Ruby itself; see
* http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
@@ -252,7 +252,7 @@
* char *current_out, *end_capa;
* PG_RB_STR_NEW( string, current_out, end_capa );
* while( data_is_going_to_be_processed ){
- * PG_RB_STR_ENSURE_CAPA( string, 2 current_out, end_capa );
+ * PG_RB_STR_ENSURE_CAPA( string, 2, current_out, end_capa );
* *current_out++ = databyte1;
* *current_out++ = databyte2;
* }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg.h new/ext/pg.h
--- old/ext/pg.h 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg.h 2015-05-14 20:50:00.000000000 +0200
@@ -133,6 +133,15 @@
typedef long suseconds_t;
#endif
+#if defined(HAVE_VARIABLE_LENGTH_ARRAYS)
+ #define PG_VARIABLE_LENGTH_ARRAY(type, name, len, maxlen) type name[(len)];
+#else
+ #define PG_VARIABLE_LENGTH_ARRAY(type, name, len, maxlen) \
+ type name[(maxlen)] = {(len)>(maxlen) ? (rb_raise(rb_eArgError, "Number of " #name " (%d) exceeds allowed maximum of " #maxlen, (len) ), (type)1) : (type)0};
+
+ #define PG_MAX_COLUMNS 4000
+#endif
+
/* The data behind each PG::Connection object */
typedef struct {
PGconn *pgconn;
@@ -313,6 +322,7 @@
VALUE pg_bin_dec_bytea _(( t_pg_coder*, char *, int, int, int, int ));
VALUE pg_text_dec_string _(( t_pg_coder*, char *, int, int, int, int ));
int pg_coder_enc_to_s _(( t_pg_coder*, VALUE, char *, VALUE *));
+int pg_text_enc_identifier _(( t_pg_coder*, VALUE, char *, VALUE *));
t_pg_coder_enc_func pg_coder_enc_func _(( t_pg_coder* ));
t_pg_coder_dec_func pg_coder_dec_func _(( t_pg_coder*, int ));
void pg_define_coder _(( const char *, void *, VALUE, VALUE ));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_connection.c new/ext/pg_connection.c
--- old/ext/pg_connection.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_connection.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_connection.c - PG::Connection class extension
- * $Id: pg_connection.c,v a7befacdef4e 2014/12/12 20:57:14 lars $
+ * $Id: pg_connection.c,v 714601d05fba 2015/02/11 20:45:04 lars $
*
*/
@@ -627,22 +627,6 @@
return rb_tainted_str_new2(host);
}
-#ifdef HAVE_PQHOSTADDR
-/*
- * call-seq:
- * conn.hostaddr()
- *
- * Returns the server numeric IP address of the connection.
- */
-static VALUE
-pgconn_hostaddr(VALUE self)
-{
- char *hostaddr = PQhostaddr(pg_get_pgconn(self));
- if (!hostaddr) return Qnil;
- return rb_tainted_str_new2(hostaddr);
-}
-#endif
-
/*
* call-seq:
* conn.port()
@@ -3013,7 +2997,9 @@
/*
* call-seq:
* PG::Connection.quote_ident( str ) -> String
+ * PG::Connection.quote_ident( array ) -> String
* conn.quote_ident( str ) -> String
+ * conn.quote_ident( array ) -> String
*
* Returns a string that is safe for inclusion in a SQL query as an
* identifier. Note: this is not a quote function for values, but for
@@ -3030,31 +3016,20 @@
* Similarly, this function also protects against special characters,
* and other things that might allow SQL injection if the identifier
* comes from an untrusted source.
+ *
+ * If the parameter is an Array, then all it's values are separately quoted
+ * and then joined by a "." character. This can be used for identifiers in
+ * the form "schema"."table"."column" .
+ *
+ * This method is functional identical to the encoder PG::TextEncoder::Identifier .
+ *
*/
static VALUE
pgconn_s_quote_ident(VALUE self, VALUE in_str)
{
VALUE ret;
- char *str = StringValuePtr(in_str);
- /* result size at most NAMEDATALEN*2 plus surrounding
- * double-quotes. */
- char buffer[NAMEDATALEN*2+2];
- unsigned int i=0,j=0;
- unsigned int str_len = RSTRING_LENINT(in_str);
-
- if(str_len >= NAMEDATALEN) {
- rb_raise(rb_eArgError,
- "Input string is longer than NAMEDATALEN-1 (%d)",
- NAMEDATALEN-1);
- }
- buffer[j++] = '"';
- for(i = 0; i < str_len && str[i]; i++) {
- if(str[i] == '"')
- buffer[j++] = '"';
- buffer[j++] = str[i];
- }
- buffer[j++] = '"';
- ret = rb_str_new(buffer,j);
+ pg_text_enc_identifier(NULL, in_str, NULL, &ret);
+
OBJ_INFECT(ret, in_str);
PG_ENCODING_SET_NOCHECK(ret, ENCODING_GET( rb_obj_class(self) == rb_cPGconn ? self : in_str ));
@@ -3835,9 +3810,6 @@
rb_define_method(rb_cPGconn, "user", pgconn_user, 0);
rb_define_method(rb_cPGconn, "pass", pgconn_pass, 0);
rb_define_method(rb_cPGconn, "host", pgconn_host, 0);
-#ifdef HAVE_PQHOSTADDR
- rb_define_method(rb_cPGconn, "hostaddr", pgconn_hostaddr, 0);
-#endif
rb_define_method(rb_cPGconn, "port", pgconn_port, 0);
rb_define_method(rb_cPGconn, "tty", pgconn_tty, 0);
#ifdef HAVE_PQCONNINFO
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_result.c new/ext/pg_result.c
--- old/ext/pg_result.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_result.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_result.c - PG::Result class extension
- * $Id: pg_result.c,v f23dd01bcb52 2014/11/17 10:47:53 kanis $
+ * $Id: pg_result.c,v 1269b8ad77b8 2015/02/06 16:38:23 lars $
*
*/
@@ -863,7 +863,7 @@
num_fields = PQnfields(this->pgresult);
for ( row = 0; row < num_rows; row++ ) {
- VALUE row_values[num_fields];
+ PG_VARIABLE_LENGTH_ARRAY(VALUE, row_values, num_fields, PG_MAX_COLUMNS)
/* populate the row */
for ( field = 0; field < num_fields; field++ ) {
@@ -892,7 +892,7 @@
VALUE results = rb_ary_new2( num_rows );
for ( row = 0; row < num_rows; row++ ) {
- VALUE row_values[num_fields];
+ PG_VARIABLE_LENGTH_ARRAY(VALUE, row_values, num_fields, PG_MAX_COLUMNS)
/* populate the row */
for ( field = 0; field < num_fields; field++ ) {
@@ -1176,7 +1176,7 @@
}
for ( row = 0; row < ntuples; row++ ) {
- VALUE row_values[nfields];
+ PG_VARIABLE_LENGTH_ARRAY(VALUE, row_values, nfields, PG_MAX_COLUMNS)
int field;
/* populate the row */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_text_decoder.c new/ext/pg_text_decoder.c
--- old/ext/pg_text_decoder.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_text_decoder.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_text_decoder.c - PG::TextDecoder module
- * $Id: pg_text_decoder.c,v b7f9daeeba29 2014/11/21 19:53:47 lars $
+ * $Id: pg_text_decoder.c,v b111c84b8445 2015/02/11 20:54:03 lars $
*
*/
@@ -293,7 +293,7 @@
}
/*
- * Document-class: PG::TextDecoder::Identifier < PG::CompositeDecoder
+ * Document-class: PG::TextDecoder::Identifier < PG::SimpleDecoder
*
* This is the decoder class for PostgreSQL identifiers.
*
@@ -305,16 +305,13 @@
static VALUE
pg_text_dec_identifier(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
- t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
- t_pg_coder_dec_func dec_func = pg_coder_dec_func(this->elem, 0);
-
/* Return value: array */
VALUE array;
VALUE elem;
int word_index = 0;
int index;
/* Use a buffer of the same length, as that will be the worst case */
- char word[len + 1];
+ PG_VARIABLE_LENGTH_ARRAY(char, word, len + 1, NAMEDATALEN)
/* The current character in the input string. */
char c;
@@ -331,7 +328,7 @@
if(c == '.' && openQuote < 2 ) {
word[word_index] = 0;
- elem = dec_func(conv, word, word_index, tuple, field, enc_idx);
+ elem = pg_text_dec_string(conv, word, word_index, tuple, field, enc_idx);
rb_ary_push(array, elem);
openQuote = 0;
@@ -353,7 +350,7 @@
}
word[word_index] = 0;
- elem = dec_func(conv, word, word_index, tuple, field, enc_idx);
+ elem = pg_text_dec_string(conv, word, word_index, tuple, field, enc_idx);
rb_ary_push(array, elem);
return array;
@@ -412,11 +409,11 @@
pg_define_coder( "String", pg_text_dec_string, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Bytea", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Bytea", pg_text_dec_bytea, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
+ /* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Identifier", rb_cPG_SimpleDecoder ); */
+ pg_define_coder( "Identifier", pg_text_dec_identifier, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Array", rb_cPG_CompositeDecoder ); */
pg_define_coder( "Array", pg_text_dec_array, rb_cPG_CompositeDecoder, rb_mPG_TextDecoder );
- /* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Identifier", rb_cPG_CompositeDecoder ); */
- pg_define_coder( "Identifier", pg_text_dec_identifier, rb_cPG_CompositeDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "FromBase64", rb_cPG_CompositeDecoder ); */
pg_define_coder( "FromBase64", pg_text_dec_from_base64, rb_cPG_CompositeDecoder, rb_mPG_TextDecoder );
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_text_encoder.c new/ext/pg_text_encoder.c
--- old/ext/pg_text_encoder.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_text_encoder.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_text_encoder.c - PG::TextEncoder module
- * $Id: pg_text_encoder.c,v 1a13e7eafeb7 2014/12/12 20:57:39 lars $
+ * $Id: pg_text_encoder.c,v b859963462b2 2015/03/13 17:39:35 lars $
*
*/
@@ -299,7 +299,7 @@
/* count data plus backslashes; detect chars needing quotes */
if (strlen == 0)
needquote = 1; /* force quotes for empty string */
- else if (strlen == 4 && pg_strncasecmp(p_in, "NULL", strlen) == 0)
+ else if (strlen == 4 && rbpg_strncasecmp(p_in, "NULL", strlen) == 0)
needquote = 1; /* force quotes for literal NULL */
else
needquote = 0;
@@ -455,39 +455,34 @@
}
}
-static int
-quote_identifier_buffer( void *_this, char *p_in, int strlen, char *p_out ){
+static char *
+quote_identifier( VALUE value, VALUE out_string, char *current_out ){
+ char *p_in = RSTRING_PTR(value);
char *ptr1;
- char *ptr2;
- int backslashs = 0;
+ size_t strlen = RSTRING_LEN(value);
+ char *end_capa = current_out;
- /* count required backlashs */
+ PG_RB_STR_ENSURE_CAPA( out_string, strlen + 2, current_out, end_capa );
+ *current_out++ = '"';
for(ptr1 = p_in; ptr1 != p_in + strlen; ptr1++) {
- if (*ptr1 == '"'){
- backslashs++;
+ char c = *ptr1;
+ if (c == '"'){
+ strlen++;
+ PG_RB_STR_ENSURE_CAPA( out_string, p_in - ptr1 + strlen + 1, current_out, end_capa );
+ *current_out++ = '"';
+ } else if (c == 0){
+ break;
}
+ *current_out++ = c;
}
+ PG_RB_STR_ENSURE_CAPA( out_string, 1, current_out, end_capa );
+ *current_out++ = '"';
- ptr1 = p_in + strlen;
- ptr2 = p_out + strlen + backslashs + 2;
- /* Write end quote */
- *--ptr2 = '"';
-
- /* Then store the escaped string on the final position, walking
- * right to left, until all backslashs are placed. */
- while( ptr1 != p_in ) {
- *--ptr2 = *--ptr1;
- if(*ptr2 == '"'){
- *--ptr2 = '"';
- }
- }
- /* Write start quote */
- *p_out = '"';
- return strlen + backslashs + 2;
+ return current_out;
}
static char *
-pg_text_enc_array_identifier(t_pg_composite_coder *this, VALUE value, VALUE string, char *out)
+pg_text_enc_array_identifier(VALUE value, VALUE string, char *out)
{
int i;
int nr_elems;
@@ -498,7 +493,7 @@
for( i=0; ielem, entry, string, out, this->needs_quotation, quote_identifier_buffer, this);
+ out = quote_identifier(entry, string, out);
if( i < nr_elems-1 ){
out = pg_rb_str_ensure_capa( string, 1, out, NULL );
*out++ = '.';
@@ -508,27 +503,29 @@
}
/*
- * Document-class: PG::TextEncoder::Identifier < PG::CompositeEncoder
+ * Document-class: PG::TextEncoder::Identifier < PG::SimpleEncoder
*
* This is the encoder class for PostgreSQL identifiers.
*
* An Array value can be used for "schema.table.column" type identifiers:
* PG::TextEncoder::Identifier.new.encode(['schema', 'table', 'column'])
- * => "schema"."table"."column"
+ * => '"schema"."table"."column"'
*
+ * This encoder can also be used per PG::Connection#quote_ident .
*/
-static int
-pg_text_enc_identifier(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate)
+int
+pg_text_enc_identifier(t_pg_coder *this, VALUE value, char *out, VALUE *intermediate)
{
- t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
-
- *intermediate = rb_str_new(NULL, 0);
- out = RSTRING_PTR(*intermediate);
-
+ UNUSED( this );
if( TYPE(value) == T_ARRAY){
- out = pg_text_enc_array_identifier(this, value, *intermediate, out);
+ *intermediate = rb_str_new(NULL, 0);
+ out = RSTRING_PTR(*intermediate);
+ out = pg_text_enc_array_identifier(value, *intermediate, out);
} else {
- out = quote_string(this->elem, value, *intermediate, out, this->needs_quotation, quote_identifier_buffer, this);
+ StringValue(value);
+ *intermediate = rb_str_new(NULL, RSTRING_LEN(value) + 2);
+ out = RSTRING_PTR(*intermediate);
+ out = quote_identifier(value, *intermediate, out);
}
rb_str_set_len( *intermediate, out - RSTRING_PTR(*intermediate) );
return -1;
@@ -651,11 +648,11 @@
pg_define_coder( "String", pg_coder_enc_to_s, rb_cPG_SimpleEncoder, rb_mPG_TextEncoder );
/* dummy = rb_define_class_under( rb_mPG_TextEncoder, "Bytea", rb_cPG_SimpleEncoder ); */
pg_define_coder( "Bytea", pg_text_enc_bytea, rb_cPG_SimpleEncoder, rb_mPG_TextEncoder );
+ /* dummy = rb_define_class_under( rb_mPG_TextEncoder, "Identifier", rb_cPG_SimpleEncoder ); */
+ pg_define_coder( "Identifier", pg_text_enc_identifier, rb_cPG_SimpleEncoder, rb_mPG_TextEncoder );
/* dummy = rb_define_class_under( rb_mPG_TextEncoder, "Array", rb_cPG_CompositeEncoder ); */
pg_define_coder( "Array", pg_text_enc_array, rb_cPG_CompositeEncoder, rb_mPG_TextEncoder );
- /* dummy = rb_define_class_under( rb_mPG_TextEncoder, "Identifier", rb_cPG_CompositeEncoder ); */
- pg_define_coder( "Identifier", pg_text_enc_identifier, rb_cPG_CompositeEncoder, rb_mPG_TextEncoder );
/* dummy = rb_define_class_under( rb_mPG_TextEncoder, "QuotedLiteral", rb_cPG_CompositeEncoder ); */
pg_define_coder( "QuotedLiteral", pg_text_enc_quoted_literal, rb_cPG_CompositeEncoder, rb_mPG_TextEncoder );
/* dummy = rb_define_class_under( rb_mPG_TextEncoder, "ToBase64", rb_cPG_CompositeEncoder ); */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_type_map_by_mri_type.c new/ext/pg_type_map_by_mri_type.c
--- old/ext/pg_type_map_by_mri_type.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_type_map_by_mri_type.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_type_map_by_mri_type.c - PG::TypeMapByMriType class extension
- * $Id: pg_type_map_by_mri_type.c,v 27987dbd0b32 2014/11/07 20:55:52 lars $
+ * $Id: pg_type_map_by_mri_type.c,v 1269b8ad77b8 2015/02/06 16:38:23 lars $
*
* This type map can be used to select value encoders based on the MRI-internal
* value type code.
@@ -39,7 +39,7 @@
typedef struct {
t_typemap typemap;
struct pg_tmbmt_converter {
- FOR_EACH_MRI_TYPE( DECLARE_CODER );
+ FOR_EACH_MRI_TYPE( DECLARE_CODER )
} coders;
} t_tmbmt;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/pg_type_map_in_ruby.c new/ext/pg_type_map_in_ruby.c
--- old/ext/pg_type_map_in_ruby.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/pg_type_map_in_ruby.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* pg_type_map_in_ruby.c - PG::TypeMapInRuby class extension
- * $Id: pg_type_map_in_ruby.c,v a38cf53a96f1 2014/12/13 21:59:57 lars $
+ * $Id: pg_type_map_in_ruby.c,v 3d89d3aae4fd 2015/01/05 16:19:41 kanis $
*
*/
@@ -212,12 +212,9 @@
rb_encoding *p_encoding = rb_enc_from_index(enc_idx);
VALUE enc = rb_enc_from_encoding(p_encoding);
/* field_str is reused in-place by pg_text_dec_copy_row(), so we need to make
- * a copy of the string buffer before used in ruby space.
- * This requires rb_str_new() instead of rb_str_dup() for Rubinius.
- */
- VALUE field_str_copy = rb_str_new(RSTRING_PTR(field_str), RSTRING_LEN(field_str));
- PG_ENCODING_SET_NOCHECK(field_str_copy, ENCODING_GET(field_str));
- OBJ_INFECT(field_str_copy, field_str);
+ * a copy of the string buffer for use in ruby space. */
+ VALUE field_str_copy = rb_str_dup(field_str);
+ rb_str_modify(field_str_copy);
return rb_funcall( this->self, s_id_typecast_copy_get, 4, field_str_copy, INT2NUM(fieldno), INT2NUM(format), enc );
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/util.c new/ext/util.c
--- old/ext/util.c 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/util.c 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,6 @@
/*
* util.c - Utils for ruby-pg
- * $Id: util.c,v 117fb5c5eed7 2014/10/15 18:36:39 lars $
+ * $Id: util.c,v b859963462b2 2015/03/13 17:39:35 lars $
*
*/
@@ -124,7 +124,7 @@
* At most n bytes will be examined from each string.
*/
int
-pg_strncasecmp(const char *s1, const char *s2, size_t n)
+rbpg_strncasecmp(const char *s1, const char *s2, size_t n)
{
while (n-- > 0)
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/util.h new/ext/util.h
--- old/ext/util.h 2015-01-05 21:59:11.000000000 +0100
+++ new/ext/util.h 2015-05-14 20:50:00.000000000 +0200
@@ -60,6 +60,6 @@
void base64_encode( char *out, char *in, int len);
int base64_decode( char *out, char *in, unsigned int len);
-int pg_strncasecmp(const char *s1, const char *s2, size_t n);
+int rbpg_strncasecmp(const char *s1, const char *s2, size_t n);
#endif /* end __utils_h */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pg/connection.rb new/lib/pg/connection.rb
--- old/lib/pg/connection.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/lib/pg/connection.rb 2015-05-14 20:50:00.000000000 +0200
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require 'pg' unless defined?( PG )
+require 'uri'
# The PostgreSQL connection class. The interface for this class is based on
# {libpq}[http://www.postgresql.org/docs/9.2/interactive/libpq.html], the C
@@ -34,46 +35,55 @@
def self::parse_connect_args( *args )
return '' if args.empty?
- # This will be swapped soon for code that makes options like those required for
- # PQconnectdbParams()/PQconnectStartParams(). For now, stick to an options string for
- # PQconnectdb()/PQconnectStart().
+ hash_arg = args.last.is_a?( Hash ) ? args.pop : {}
+ option_string = ''
+ options = {}
# Parameter 'fallback_application_name' was introduced in PostgreSQL 9.0
# together with PQescapeLiteral().
- if PG::Connection.instance_methods.find{|m| m.to_sym == :escape_literal }
- appname = $0.sub(/^(.{30}).{4,}(.{30})$/){ $1+"..."+$2 }
- appname = PG::Connection.quote_connstr( appname )
- connopts = ["fallback_application_name=#{appname}"]
- else
- connopts = []
+ if PG::Connection.instance_methods.find {|m| m.to_sym == :escape_literal }
+ options[:fallback_application_name] = $0.sub( /^(.{30}).{4,}(.{30})$/ ){ $1+"..."+$2 }
end
- # Handle an options hash first
- if args.last.is_a?( Hash )
- opthash = args.pop
- opthash.each do |key, val|
- connopts.push( "%s=%s" % [key, PG::Connection.quote_connstr(val)] )
+ if args.length == 1
+ case args.first
+ when URI, URI.regexp
+ uri = URI(args.first)
+ options.merge!( Hash[URI.decode_www_form( uri.query )] ) if uri.query
+ when /=/
+ # Option string style
+ option_string = args.first.to_s
+ else
+ # Positional parameters
+ options[CONNECT_ARGUMENT_ORDER.first.to_sym] = args.first
end
- end
-
- # Option string style
- if args.length == 1 && args.first.to_s.index( '=' )
- connopts.unshift( args.first )
-
- # Append positional parameters
else
- args.each_with_index do |val, i|
- next unless val # Skip nil placeholders
+ max = CONNECT_ARGUMENT_ORDER.length
+ raise ArgumentError,
+ "Extra positional parameter %d: %p" % [ max + 1, args[max] ] if args.length > max
- key = CONNECT_ARGUMENT_ORDER[ i ] or
- raise ArgumentError, "Extra positional parameter %d: %p" % [ i+1, val ]
- connopts.push( "%s=%s" % [key, PG::Connection.quote_connstr(val.to_s)] )
+ CONNECT_ARGUMENT_ORDER.zip( args ) do |(k,v)|
+ options[ k.to_sym ] = v if v
end
end
- return connopts.join(' ')
+ options.merge!( hash_arg )
+
+ if uri
+ uri.host = nil if options[:host]
+ uri.port = nil if options[:port]
+ uri.user = nil if options[:user]
+ uri.password = nil if options[:password]
+ uri.path = '' if options[:dbname]
+ uri.query = URI.encode_www_form( options )
+ return uri.to_s.sub( /^#{uri.scheme}:(?!\/\/)/, "#{uri.scheme}://" )
+ else
+ option_string += ' ' unless option_string.empty? && options.empty?
+ return option_string + options.map { |k,v| "#{k}=#{quote_connstr(v)}" }.join( ' ' )
+ end
end
+
# call-seq:
# conn.copy_data( sql ) {|sql_result| ... } -> PG::Result
#
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pg/text_decoder.rb new/lib/pg/text_decoder.rb
--- old/lib/pg/text_decoder.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/lib/pg/text_decoder.rb 2015-05-14 20:50:00.000000000 +0200
@@ -27,11 +27,11 @@
end
class TimestampWithTimeZone < SimpleDecoder
- ISO_DATETIME_WITH_TIMEZONE = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?([-\+]\d\d)\z/
+ ISO_DATETIME_WITH_TIMEZONE = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?([-\+]\d\d):?(\d\d)?:?(\d\d)?\z/
def decode(string, tuple=nil, field=nil)
if string =~ ISO_DATETIME_WITH_TIMEZONE
- Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r, "#{$8}:00"
+ Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r, "#{$8}:#{$9 || '00'}:#{$10 || '00'}"
else
string
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pg.rb new/lib/pg.rb
--- old/lib/pg.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/lib/pg.rb 2015-05-14 20:50:00.000000000 +0200
@@ -24,10 +24,10 @@
module PG
# Library version
- VERSION = '0.18.1'
+ VERSION = '0.18.2'
# VCS revision
- REVISION = %q$Revision: ba5aff64b5cb $
+ REVISION = %q$Revision: 7d31b04e7913 $
class NotAllCopyDataRetrieved < PG::Error
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2015-01-05 21:59:11.000000000 +0100
+++ new/metadata 2015-05-14 20:50:00.000000000 +0200
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: pg
version: !ruby/object:Gem::Version
- version: 0.18.1
+ version: 0.18.2
platform: ruby
authors:
- Michael Granger
@@ -13,7 +13,7 @@
-----BEGIN CERTIFICATE-----
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
- HhcNMTQwMzE5MDQzNTI2WhcNMTUwMzE5MDQzNTI2WjA+MQwwCgYDVQQDDANnZWQx
+ HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
+Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
@@ -24,125 +24,125 @@
AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSZ0hCV
qoHr122fGKelqffzEQBhszAcBgNVHREEFTATgRFnZWRARmFlcmllTVVELm9yZzAc
BgNVHRIEFTATgRFnZWRARmFlcmllTVVELm9yZzANBgkqhkiG9w0BAQUFAAOCAQEA
- TuL1Bzl6TBs1YEzEubFHb9XAPgehWzzUudjDKzTRd+uyZmxnomBqTCQjT5ucNRph
- 3jZ6bhLNooLQxTjIuHodeGcEMHZdt4Yi7SyPmw5Nry12z6wrDp+5aGps3HsE5WsQ
- Zq2EuyEOc96g31uoIvjNdieKs+1kE+K+dJDjtw+wTH2i63P7r6N/NfPPXpxsFquo
- wcYRRrHdR7GhdJeT+V8Q8Bi5bglCUGdx+8scMgkkePc98k9osQHypbACmzO+Bqkv
- c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
- ggcrPfcYeTwWlfZPu2LrBg==
+ lUKo3NXePpuvN3QGsOLJ6QhNd4+Q9Rz75GipuMrCl296V8QFkd2gg9EG44Pqtk+9
+ Zac8TkKc9bCSR0snakp+cCPplVvZF0/gMzkSTUJkDBHlNV16z73CyWpbQQa+iLJ4
+ uisI6gF2ZXK919MYLn2bFJfb7OsCvVfyTPqq8afPY+rq9vlf9ZPwU49AlD8bPRic
+ 0LX0gO5ykvETIOv+WgGcqp96ceNi9XVuJMh20uWuw6pmv/Ub2RqAf82jQSbpz09G
+ G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
+ xn3DzOkDE6NYbk8gC9rTsA==
-----END CERTIFICATE-----
-date: 2015-01-05 00:00:00.000000000 Z
+date: 2015-05-14 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: hoe-mercurial
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '1.4'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '1.4'
- !ruby/object:Gem::Dependency
name: hoe-deveiate
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.6'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.6'
- !ruby/object:Gem::Dependency
name: hoe-highline
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.2'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.2'
- !ruby/object:Gem::Dependency
name: rdoc
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '4.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '4.0'
- !ruby/object:Gem::Dependency
name: rake-compiler
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.9'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.9'
- !ruby/object:Gem::Dependency
name: hoe
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '3.12'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '3.12'
- !ruby/object:Gem::Dependency
name: hoe-bundler
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '1.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '1.0'
- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '3.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '3.0'
description: |-
@@ -202,7 +202,7 @@
- ext/pg_type_map_in_ruby.c
- ext/util.c
files:
-- .gemtest
+- ".gemtest"
- BSDL
- ChangeLog
- Contributors.rdoc
@@ -295,27 +295,27 @@
metadata: {}
post_install_message:
rdoc_options:
-- -f
+- "-f"
- fivefish
-- -t
+- "-t"
- 'pg: The Ruby Interface to PostgreSQL'
-- -m
+- "-m"
- README.rdoc
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - - '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 1.9.3
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - - '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.4.5
+rubygems_version: 2.4.6
signing_key:
specification_version: 4
summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
Files old/metadata.gz.sig and new/metadata.gz.sig differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/connection_spec.rb new/spec/pg/connection_spec.rb
--- old/spec/pg/connection_spec.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/spec/pg/connection_spec.rb 2015-05-14 20:50:00.000000000 +0200
@@ -45,6 +45,14 @@
expect( optstring ).to match( /(^|\s)user='jrandom'/ )
end
+ it "can create a connection option string from an option string and a hash" do
+ optstring = described_class.parse_connect_args( 'dbname=original', :user => 'jrandom' )
+
+ expect( optstring ).to be_a( String )
+ expect( optstring ).to match( /(^|\s)dbname=original/ )
+ expect( optstring ).to match( /(^|\s)user='jrandom'/ )
+ end
+
it "escapes single quotes and backslashes in connection parameters" do
expect(
described_class.parse_connect_args( "DB 'browser' \\" )
@@ -52,18 +60,72 @@
end
+ let(:uri) { 'postgresql://user:pass@pgsql.example.com:222/db01?sslmode=require' }
+
+ it "can connect using a URI" do
+ string = described_class.parse_connect_args( uri )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql://user:pass@pgsql.example.com:222/db01\?} )
+ expect( string ).to match( %r{\?.*sslmode=require} )
+
+ string = described_class.parse_connect_args( URI.parse(uri) )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql://user:pass@pgsql.example.com:222/db01\?} )
+ expect( string ).to match( %r{\?.*sslmode=require} )
+ end
+
+ it "can create a connection URI from a URI and a hash" do
+ string = described_class.parse_connect_args( uri, :connect_timeout => 2 )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql://user:pass@pgsql.example.com:222/db01\?} )
+ expect( string ).to match( %r{\?.*sslmode=require} )
+ expect( string ).to match( %r{\?.*connect_timeout=2} )
+
+ string = described_class.parse_connect_args( uri,
+ :user => 'a',
+ :password => 'b',
+ :host => 'localhost',
+ :port => 555,
+ :dbname => 'x' )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql://\?} )
+ expect( string ).to match( %r{\?.*user=a} )
+ expect( string ).to match( %r{\?.*password=b} )
+ expect( string ).to match( %r{\?.*host=localhost} )
+ expect( string ).to match( %r{\?.*port=555} )
+ expect( string ).to match( %r{\?.*dbname=x} )
+ end
+
+ it "can create a connection URI with a non-standard domain socket directory" do
+ string = described_class.parse_connect_args( 'postgresql://%2Fvar%2Flib%2Fpostgresql/dbname' )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql://%2Fvar%2Flib%2Fpostgresql/dbname} )
+
+ string = described_class.
+ parse_connect_args( 'postgresql:///dbname', :host => '/var/lib/postgresql' )
+
+ expect( string ).to be_a( String )
+ expect( string ).to match( %r{^postgresql:///dbname\?} )
+ expect( string ).to match( %r{\?.*host=%2Fvar%2Flib%2Fpostgresql} )
+ end
+
it "connects with defaults if no connection parameters are given" do
expect( described_class.parse_connect_args ).to eq( '' )
end
it "connects successfully with connection string" do
- tmpconn = described_class.connect(@conninfo)
+ tmpconn = described_class.connect( @conninfo )
expect( tmpconn.status ).to eq( PG::CONNECTION_OK )
tmpconn.finish
end
it "connects using 7 arguments converted to strings" do
- tmpconn = described_class.connect('localhost', @port, nil, nil, :test, nil, nil)
+ tmpconn = described_class.connect( 'localhost', @port, nil, nil, :test, nil, nil )
expect( tmpconn.status ).to eq( PG::CONNECTION_OK )
tmpconn.finish
end
@@ -89,8 +151,13 @@
it "raises an exception when connecting with an invalid number of arguments" do
expect {
- described_class.connect( 1, 2, 3, 4, 5, 6, 7, 'extra' )
- }.to raise_error( ArgumentError, /extra positional parameter/i )
+ described_class.connect( 1, 2, 3, 4, 5, 6, 7, 'the-extra-arg' )
+ }.to raise_error do |error|
+ expect( error ).to be_an( ArgumentError )
+ expect( error.message ).to match( /extra positional parameter/i )
+ expect( error.message ).to match( /8/ )
+ expect( error.message ).to match( /the-extra-arg/ )
+ end
end
it "can connect asynchronously", :socket_io do
@@ -162,8 +229,6 @@
expect( @conn.user ).to be_a_kind_of( String )
expect( @conn.pass ).to eq( "" )
expect( @conn.host ).to eq( "localhost" )
- # TODO: Not sure why libpq returns a NULL ptr instead of "127.0.0.1"
- expect( @conn.hostaddr ).to eq( nil ) if @conn.server_version >= 9_04_00
expect( @conn.port ).to eq( 54321 )
expect( @conn.tty ).to eq( "" )
expect( @conn.options ).to eq( "" )
@@ -1128,9 +1193,20 @@
expect( escaped.encoding ).to eq( Encoding::ISO8859_1 )
expect( escaped ).to eq( "\"string to\"" )
end
+ end
+ it "can quote bigger strings with quote_ident" do
+ original = "'01234567\"" * 100
+ escaped = described_class.quote_ident( original + "\0afterzero" )
+ expect( escaped ).to eq( "\"" + original.gsub("\"", "\"\"") + "\"" )
end
+ it "can quote Arrays with quote_ident" do
+ original = "'01234567\""
+ escaped = described_class.quote_ident( [original]*3 )
+ expected = ["\"" + original.gsub("\"", "\"\"") + "\""] * 3
+ expect( escaped ).to eq( expected.join(".") )
+ end
describe "Ruby 1.9.x default_internal encoding" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/pg/type_spec.rb new/spec/pg/type_spec.rb
--- old/spec/pg/type_spec.rb 2015-01-05 21:59:11.000000000 +0100
+++ new/spec/pg/type_spec.rb 2015-05-14 20:50:00.000000000 +0200
@@ -15,6 +15,8 @@
let!(:textdec_string) { PG::TextDecoder::String.new }
let!(:textenc_timestamp) { PG::TextEncoder::TimestampWithoutTimeZone.new }
let!(:textdec_timestamp) { PG::TextDecoder::TimestampWithoutTimeZone.new }
+ let!(:textenc_timestamptz) { PG::TextEncoder::TimestampWithTimeZone.new }
+ let!(:textdec_timestamptz) { PG::TextDecoder::TimestampWithTimeZone.new }
let!(:textenc_bytea) { PG::TextEncoder::Bytea.new }
let!(:textdec_bytea) { PG::TextDecoder::Bytea.new }
let!(:binaryenc_int2) { PG::BinaryEncoder::Int2.new }
@@ -85,6 +87,48 @@
expect( textdec_bytea.decode("\\377\\000") ).to eq( "\xff\0".b )
end
+ context 'timestamps' do
+ it 'decodes timestamps without timezone' do
+ expect( textdec_timestamp.decode('2016-01-02 23:23:59.123456') ).
+ to be_within(0.000001).of( Time.new(2016,01,02, 23, 23, 59.123456) )
+ end
+ it 'decodes timestamps with hour timezone' do
+ expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-04') ).
+ to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:00") )
+ expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511+10') ).
+ to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "+10:00") )
+ end
+ it 'decodes timestamps with hour:minute timezone' do
+ expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-04:15') ).
+ to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:15") )
+ expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511-0430') ).
+ to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "-04:30") )
+ expect( textdec_timestamptz.decode('2015-01-26 17:26:42.691511+10:45') ).
+ to be_within(0.000001).of( Time.new(2015,01,26, 17, 26, 42.691511, "+10:45") )
+ end
+ it 'decodes timestamps with hour:minute:sec timezone' do
+ # SET TIME ZONE 'Europe/Dublin'; -- Was UTC−00:25:21 until 1916
+ # SELECT '1900-01-01'::timestamptz;
+ # -- "1900-01-01 00:00:00-00:25:21"
+ expect( textdec_timestamptz.decode('1916-01-01 00:00:00-00:25:21') ).
+ to be_within(0.000001).of( Time.new(1916, 1, 1, 0, 0, 0, "-00:25:21") )
+ end
+ end
+
+ context 'identifier quotation' do
+ it 'should build an array out of an quoted identifier string' do
+ quoted_type = PG::TextDecoder::Identifier.new
+ expect( quoted_type.decode(%["A.".".B"]) ).to eq( ["A.", ".B"] )
+ expect( quoted_type.decode(%["'A"".""B'"]) ).to eq( ['\'A"."B\''] )
+ end
+
+ it 'should split unquoted identifier string' do
+ quoted_type = PG::TextDecoder::Identifier.new
+ expect( quoted_type.decode(%[a.b]) ).to eq( ['a','b'] )
+ expect( quoted_type.decode(%[a]) ).to eq( ['a'] )
+ end
+ end
+
it "should raise when decode method is called with wrong args" do
expect{ textdec_int.decode() }.to raise_error(ArgumentError)
expect{ textdec_int.decode("123", 2, 3, 4) }.to raise_error(ArgumentError)
@@ -156,6 +200,15 @@
expect( textenc_bytea.encode("\x00\x01\x02\x03\xef".b) ).to eq( "\\x00010203ef" )
end
+ context 'identifier quotation' do
+ it 'should quote and escape identifier' do
+ quoted_type = PG::TextEncoder::Identifier.new
+ expect( quoted_type.encode(['schema','table','col']) ).to eq( %["schema"."table"."col"] )
+ expect( quoted_type.encode(['A.','.B']) ).to eq( %["A.".".B"] )
+ expect( quoted_type.encode(%['A"."B']) ).to eq( %["'A"".""B'"] )
+ end
+ end
+
it "should encode with ruby encoder" do
expect( intenc_incrementer.encode(3) ).to eq( "4 " )
end
@@ -347,20 +400,6 @@
array_type = PG::TextDecoder::Array.new elements_type: nil
expect( array_type.decode(%[{3,4}]) ).to eq( ['3','4'] )
end
-
- context 'identifier quotation' do
- it 'should build an array out of an quoted identifier string' do
- quoted_type = PG::TextDecoder::Identifier.new elements_type: textdec_string
- expect( quoted_type.decode(%["A.".".B"]) ).to eq( ["A.", ".B"] )
- expect( quoted_type.decode(%["'A"".""B'"]) ).to eq( ['\'A"."B\''] )
- end
-
- it 'should split unquoted identifier string' do
- quoted_type = PG::TextDecoder::Identifier.new elements_type: textdec_string
- expect( quoted_type.decode(%[a.b]) ).to eq( ['a','b'] )
- expect( quoted_type.decode(%[a]) ).to eq( ['a'] )
- end
- end
end
describe '#encode' do
@@ -422,22 +461,6 @@
expect( textenc_float_array.encode(1234) ).to eq( "1234" )
end
- context 'identifier quotation' do
- it 'should quote and escape identifier' do
- quoted_type = PG::TextEncoder::Identifier.new elements_type: textenc_string
- expect( quoted_type.encode(['schema','table','col']) ).to eq( %["schema"."table"."col"] )
- expect( quoted_type.encode(['A.','.B']) ).to eq( %["A.".".B"] )
- expect( quoted_type.encode(%['A"."B']) ).to eq( %["'A"".""B'"] )
- end
-
- it 'shouldn\'t quote or escape identifier if requested to not do' do
- quoted_type = PG::TextEncoder::Identifier.new elements_type: textenc_string,
- needs_quotation: false
- expect( quoted_type.encode(['a','b']) ).to eq( %[a.b] )
- expect( quoted_type.encode(%[a.b]) ).to eq( %[a.b] )
- end
- end
-
context 'literal quotation' do
it 'should quote and escape literals' do
quoted_type = PG::TextEncoder::QuotedLiteral.new elements_type: textenc_string_array