pg 0.19.0 → 0.19.1.pre20170115074000

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,19 @@
1
+ == v0.19.1 [YYYY-MM-DD] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+ - Update error codes to PostgreSQL-9.6
5
+ - Update Windows binary gems to Ruby-2.4, PostgreSQL 9.6.1 and
6
+ OpenSSL 1.0.2j.
7
+
8
+ Bugfixes:
9
+ - Use secure JSON methods for JSON (de)serialisation. #248
10
+ - Fix Result#inspect on a cleared result.
11
+ - Fix test case that failed on Ruby-2.4. #255
12
+
13
+ Documentation fixes:
14
+ - Talk about Integer instead of Fixnum.
15
+ - Fix method signature of Coder#encode.
16
+
1
17
  == v0.19.0 [2016-09-21] Michael Granger <ged@FaerieMUD.org>
2
18
 
3
19
  - Deprecate Ruby 1.9
data/Rakefile CHANGED
@@ -60,8 +60,8 @@ $hoespec = Hoe.spec 'pg' do
60
60
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
61
61
  self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
62
 
63
- self.dependency 'rake-compiler', '~> 0.9', :developer
64
- self.dependency 'rake-compiler-dock', '~> 0.5', :developer
63
+ self.dependency 'rake-compiler', '~> 1.0.3', :developer
64
+ self.dependency 'rake-compiler-dock', '~> 0.6.0', :developer
65
65
  self.dependency 'hoe', '~> 3.12', :developer
66
66
  self.dependency 'hoe-deveiate', '~> 0.6', :developer
67
67
  self.dependency 'hoe-bundler', '~> 1.0', :developer
@@ -185,7 +185,7 @@ end
185
185
 
186
186
  desc "Update list of server error codes"
187
187
  task :update_error_codes do
188
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
188
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL9_6_1"
189
189
 
190
190
  ERRORCODES_TXT = "ext/errorcodes.txt"
191
191
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
@@ -29,8 +29,8 @@ class CrossLibrary < OpenStruct
29
29
  self.host_platform = toolchain
30
30
 
31
31
  # Cross-compilation constants
32
- self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.2h'
33
- self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.5.4'
32
+ self.openssl_version = ENV['OPENSSL_VERSION'] || '1.0.2j'
33
+ self.postgresql_version = ENV['POSTGRESQL_VERSION'] || '9.6.1'
34
34
 
35
35
  # Check if symlinks work in the current working directory.
36
36
  # This fails, if rake-compiler-dock is running on a Windows box.
@@ -291,11 +291,12 @@ task 'gem:windows' => ['ChangeLog'] do
291
291
  # Copy gem signing key and certs to be accessable from the docker container
292
292
  mkdir_p 'build/gem'
293
293
  sh "cp ~/.gem/gem-*.pem build/gem/ || true"
294
+ sh "bundle package"
294
295
 
295
296
  RakeCompilerDock.sh <<-EOT
296
297
  mkdir ~/.gem &&
297
298
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
298
- bundle install &&
299
- rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.6:2.0.0:1.9.3
299
+ bundle install --local &&
300
+ rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.6:2.0.0
300
301
  EOT
301
302
  end
@@ -373,6 +373,10 @@
373
373
  VALUE klass = define_error_class( "InFailedSqlTransaction", "25" );
374
374
  register_error_class( "25P02", klass );
375
375
  }
376
+ {
377
+ VALUE klass = define_error_class( "IdleInTransactionSessionTimeout", "25" );
378
+ register_error_class( "25P03", klass );
379
+ }
376
380
  {
377
381
  VALUE klass = define_error_class( "InvalidSqlStatementName", NULL );
378
382
  register_error_class( "26000", klass );
@@ -793,6 +797,11 @@
793
797
  VALUE klass = define_error_class( "DuplicateFile", "58" );
794
798
  register_error_class( "58P02", klass );
795
799
  }
800
+ {
801
+ VALUE klass = define_error_class( "SnapshotTooOld", NULL );
802
+ register_error_class( "72000", klass );
803
+ register_error_class( "72", klass );
804
+ }
796
805
  {
797
806
  VALUE klass = define_error_class( "ConfigFileError", NULL );
798
807
  register_error_class( "F0000", klass );
@@ -15,6 +15,9 @@
15
15
  # src/pl/plpgsql/src/plerrcodes.h
16
16
  # a list of PL/pgSQL condition names and their SQLSTATE codes
17
17
  #
18
+ # src/pl/tcl/pltclerrcodes.h
19
+ # the same, for PL/Tcl
20
+ #
18
21
  # doc/src/sgml/errcodes-list.sgml
19
22
  # a SGML table of error codes for inclusion in the documentation
20
23
  #
@@ -229,6 +232,7 @@ Section: Class 25 - Invalid Transaction State
229
232
  25007 E ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED schema_and_data_statement_mixing_not_supported
230
233
  25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
231
234
  25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
235
+ 25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
232
236
 
233
237
  Section: Class 26 - Invalid SQL Statement Name
234
238
 
@@ -413,6 +417,10 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
413
417
  58P01 E ERRCODE_UNDEFINED_FILE undefined_file
414
418
  58P02 E ERRCODE_DUPLICATE_FILE duplicate_file
415
419
 
420
+ Section: Class 72 - Snapshot Failure
421
+ # (class borrowed from Oracle)
422
+ 72000 E ERRCODE_SNAPSHOT_TOO_OLD snapshot_too_old
423
+
416
424
  Section: Class F0 - Configuration File Error
417
425
 
418
426
  # (PostgreSQL-specific error class)
data/ext/pg.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg.c - Toplevel extension
3
- * $Id: pg.c,v c77d0997b4e4 2016/08/20 17:30:03 ged $
3
+ * $Id$
4
4
  *
5
5
  * Author/s:
6
6
  *
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_column_map.c - PG::ColumnMap class extension
3
- * $Id: pg_binary_decoder.c,v fcf731d3dff7 2015/09/08 12:25:06 jfali $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_column_map.c - PG::ColumnMap class extension
3
- * $Id: pg_binary_encoder.c,v e61a06f1f5ed 2015/12/25 21:14:21 lars $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -105,7 +105,7 @@ pg_composite_decoder_allocate( VALUE klass )
105
105
 
106
106
  /*
107
107
  * call-seq:
108
- * coder.encode( value )
108
+ * coder.encode( value [, encoding] )
109
109
  *
110
110
  * Encodes the given Ruby object into string representation, without
111
111
  * sending data to/from the database server.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_connection.c - PG::Connection class extension
3
- * $Id: pg_connection.c,v 4d9c4ee44d11 2016/09/04 17:32:03 lars $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -352,9 +352,9 @@ pgconn_s_connect_start( int argc, VALUE *argv, VALUE klass )
352
352
  #ifdef HAVE_PQPING
353
353
  /*
354
354
  * call-seq:
355
- * PG::Connection.ping(connection_hash) -> Fixnum
356
- * PG::Connection.ping(connection_string) -> Fixnum
357
- * PG::Connection.ping(host, port, options, tty, dbname, login, password) -> Fixnum
355
+ * PG::Connection.ping(connection_hash) -> Integer
356
+ * PG::Connection.ping(connection_string) -> Integer
357
+ * PG::Connection.ping(host, port, options, tty, dbname, login, password) -> Integer
358
358
  *
359
359
  * Check server status.
360
360
  *
@@ -457,7 +457,7 @@ pgconn_s_encrypt_password(VALUE self, VALUE password, VALUE username)
457
457
 
458
458
  /*
459
459
  * call-seq:
460
- * conn.connect_poll() -> Fixnum
460
+ * conn.connect_poll() -> Integer
461
461
  *
462
462
  * Returns one of:
463
463
  * [+PGRES_POLLING_READING+]
@@ -566,7 +566,7 @@ pgconn_reset_start(VALUE self)
566
566
 
567
567
  /*
568
568
  * call-seq:
569
- * conn.reset_poll -> Fixnum
569
+ * conn.reset_poll -> Integer
570
570
  *
571
571
  * Checks the status of a connection reset operation.
572
572
  * See #connect_start and #connect_poll for
@@ -805,7 +805,7 @@ pgconn_error_message(VALUE self)
805
805
 
806
806
  /*
807
807
  * call-seq:
808
- * conn.socket() -> Fixnum
808
+ * conn.socket() -> Integer
809
809
  *
810
810
  * Returns the socket's file descriptor for this connection.
811
811
  * <tt>IO.for_fd()</tt> can be used to build a proper IO object to the socket.
@@ -880,7 +880,7 @@ pgconn_socket_io(VALUE self)
880
880
 
881
881
  /*
882
882
  * call-seq:
883
- * conn.backend_pid() -> Fixnum
883
+ * conn.backend_pid() -> Integer
884
884
  *
885
885
  * Returns the process ID of the backend server
886
886
  * process for this connection.
@@ -1234,8 +1234,8 @@ pgconn_query_assign_typemap( VALUE self, struct query_params_data *paramsData )
1234
1234
  * Each element of the +params+ array may be either:
1235
1235
  * a hash of the form:
1236
1236
  * {:value => String (value of bind parameter)
1237
- * :type => Fixnum (oid of type of bind parameter)
1238
- * :format => Fixnum (0 for text, 1 for binary)
1237
+ * :type => Integer (oid of type of bind parameter)
1238
+ * :format => Integer (0 for text, 1 for binary)
1239
1239
  * }
1240
1240
  * or, it may be a String. If it is a string, that is equivalent to the hash:
1241
1241
  * { :value => <string value>, :type => 0, :format => 0 }
@@ -1377,7 +1377,7 @@ pgconn_prepare(int argc, VALUE *argv, VALUE self)
1377
1377
  * SQL query. Each element of the +params+ array may be either:
1378
1378
  * a hash of the form:
1379
1379
  * {:value => String (value of bind parameter)
1380
- * :format => Fixnum (0 for text, 1 for binary)
1380
+ * :format => Integer (0 for text, 1 for binary)
1381
1381
  * }
1382
1382
  * or, it may be a String. If it is a string, that is equivalent to the hash:
1383
1383
  * { :value => <string value>, :format => 0 }
@@ -1793,8 +1793,8 @@ pgconn_set_single_row_mode(VALUE self)
1793
1793
  * Each element of the +params+ array may be either:
1794
1794
  * a hash of the form:
1795
1795
  * {:value => String (value of bind parameter)
1796
- * :type => Fixnum (oid of type of bind parameter)
1797
- * :format => Fixnum (0 for text, 1 for binary)
1796
+ * :type => Integer (oid of type of bind parameter)
1797
+ * :format => Integer (0 for text, 1 for binary)
1798
1798
  * }
1799
1799
  * or, it may be a String. If it is a string, that is equivalent to the hash:
1800
1800
  * { :value => <string value>, :type => 0, :format => 0 }
@@ -1940,7 +1940,7 @@ pgconn_send_prepare(int argc, VALUE *argv, VALUE self)
1940
1940
  * SQL query. Each element of the +params+ array may be either:
1941
1941
  * a hash of the form:
1942
1942
  * {:value => String (value of bind parameter)
1943
- * :format => Fixnum (0 for text, 1 for binary)
1943
+ * :format => Integer (0 for text, 1 for binary)
1944
1944
  * }
1945
1945
  * or, it may be a String. If it is a string, that is equivalent to the hash:
1946
1946
  * { :value => <string value>, :format => 0 }
@@ -2724,7 +2724,7 @@ pgconn_get_copy_data(int argc, VALUE *argv, VALUE self )
2724
2724
 
2725
2725
  /*
2726
2726
  * call-seq:
2727
- * conn.set_error_verbosity( verbosity ) -> Fixnum
2727
+ * conn.set_error_verbosity( verbosity ) -> Integer
2728
2728
  *
2729
2729
  * Sets connection's verbosity to _verbosity_ and returns
2730
2730
  * the previous setting. Available settings are:
@@ -3280,7 +3280,7 @@ pgconn_ssl_attribute_names(VALUE self)
3280
3280
 
3281
3281
  /*
3282
3282
  * call-seq:
3283
- * conn.lo_creat( [mode] ) -> Fixnum
3283
+ * conn.lo_creat( [mode] ) -> Integer
3284
3284
  *
3285
3285
  * Creates a large object with mode _mode_. Returns a large object Oid.
3286
3286
  * On failure, it raises PG::Error.
@@ -3307,7 +3307,7 @@ pgconn_locreat(int argc, VALUE *argv, VALUE self)
3307
3307
 
3308
3308
  /*
3309
3309
  * call-seq:
3310
- * conn.lo_create( oid ) -> Fixnum
3310
+ * conn.lo_create( oid ) -> Integer
3311
3311
  *
3312
3312
  * Creates a large object with oid _oid_. Returns the large object Oid.
3313
3313
  * On failure, it raises PG::Error.
@@ -3328,7 +3328,7 @@ pgconn_locreate(VALUE self, VALUE in_lo_oid)
3328
3328
 
3329
3329
  /*
3330
3330
  * call-seq:
3331
- * conn.lo_import(file) -> Fixnum
3331
+ * conn.lo_import(file) -> Integer
3332
3332
  *
3333
3333
  * Import a file to a large object. Returns a large object Oid.
3334
3334
  *
@@ -3373,7 +3373,7 @@ pgconn_loexport(VALUE self, VALUE lo_oid, VALUE filename)
3373
3373
 
3374
3374
  /*
3375
3375
  * call-seq:
3376
- * conn.lo_open( oid, [mode] ) -> Fixnum
3376
+ * conn.lo_open( oid, [mode] ) -> Integer
3377
3377
  *
3378
3378
  * Open a large object of _oid_. Returns a large object descriptor
3379
3379
  * instance on success. The _mode_ argument specifies the mode for
@@ -3404,7 +3404,7 @@ pgconn_loopen(int argc, VALUE *argv, VALUE self)
3404
3404
 
3405
3405
  /*
3406
3406
  * call-seq:
3407
- * conn.lo_write( lo_desc, buffer ) -> Fixnum
3407
+ * conn.lo_write( lo_desc, buffer ) -> Integer
3408
3408
  *
3409
3409
  * Writes the string _buffer_ to the large object _lo_desc_.
3410
3410
  * Returns the number of bytes written.
@@ -3471,7 +3471,7 @@ pgconn_loread(VALUE self, VALUE in_lo_desc, VALUE in_len)
3471
3471
 
3472
3472
  /*
3473
3473
  * call-seq:
3474
- * conn.lo_lseek( lo_desc, offset, whence ) -> Fixnum
3474
+ * conn.lo_lseek( lo_desc, offset, whence ) -> Integer
3475
3475
  *
3476
3476
  * Move the large object pointer _lo_desc_ to offset _offset_.
3477
3477
  * Valid values for _whence_ are +SEEK_SET+, +SEEK_CUR+, and +SEEK_END+.
@@ -3493,7 +3493,7 @@ pgconn_lolseek(VALUE self, VALUE in_lo_desc, VALUE offset, VALUE whence)
3493
3493
 
3494
3494
  /*
3495
3495
  * call-seq:
3496
- * conn.lo_tell( lo_desc ) -> Fixnum
3496
+ * conn.lo_tell( lo_desc ) -> Integer
3497
3497
  *
3498
3498
  * Returns the current position of the large object _lo_desc_.
3499
3499
  */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_result.c - PG::Result class extension
3
- * $Id: pg_result.c,v 982082c0d77b 2016/01/31 19:28:55 ged $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -302,7 +302,7 @@ static void pgresult_init_fnames(VALUE self)
302
302
 
303
303
  /*
304
304
  * call-seq:
305
- * res.result_status() -> Fixnum
305
+ * res.result_status() -> Integer
306
306
  *
307
307
  * Returns the status of the query. The status value is one of:
308
308
  * * +PGRES_EMPTY_QUERY+
@@ -414,7 +414,7 @@ pgresult_error_field(VALUE self, VALUE field)
414
414
 
415
415
  /*
416
416
  * call-seq:
417
- * res.ntuples() -> Fixnum
417
+ * res.ntuples() -> Integer
418
418
  *
419
419
  * Returns the number of tuples in the query result.
420
420
  */
@@ -466,7 +466,7 @@ pgresult_fname(VALUE self, VALUE index)
466
466
 
467
467
  /*
468
468
  * call-seq:
469
- * res.fnumber( name ) -> Fixnum
469
+ * res.fnumber( name ) -> Integer
470
470
  *
471
471
  * Returns the index of the field specified by the string +name+.
472
472
  * The given +name+ is treated like an identifier in an SQL command, that is,
@@ -527,7 +527,7 @@ pgresult_ftable(VALUE self, VALUE column_number)
527
527
 
528
528
  /*
529
529
  * call-seq:
530
- * res.ftablecol( column_number ) -> Fixnum
530
+ * res.ftablecol( column_number ) -> Integer
531
531
  *
532
532
  * Returns the column number (within its table) of the table from
533
533
  * which the column _column_number_ is made up.
@@ -552,7 +552,7 @@ pgresult_ftablecol(VALUE self, VALUE column_number)
552
552
 
553
553
  /*
554
554
  * call-seq:
555
- * res.fformat( column_number ) -> Fixnum
555
+ * res.fformat( column_number ) -> Integer
556
556
  *
557
557
  * Returns the format (0 for text, 1 for binary) of column
558
558
  * _column_number_.
@@ -696,7 +696,7 @@ pgresult_getisnull(VALUE self, VALUE tup_num, VALUE field_num)
696
696
 
697
697
  /*
698
698
  * call-seq:
699
- * res.getlength( tup_num, field_num ) -> Fixnum
699
+ * res.getlength( tup_num, field_num ) -> Integer
700
700
  *
701
701
  * Returns the (String) length of the field in bytes.
702
702
  *
@@ -721,7 +721,7 @@ pgresult_getlength(VALUE self, VALUE tup_num, VALUE field_num)
721
721
 
722
722
  /*
723
723
  * call-seq:
724
- * res.nparams() -> Fixnum
724
+ * res.nparams() -> Integer
725
725
  *
726
726
  * Returns the number of parameters of a prepared statement.
727
727
  * Only useful for the result returned by conn.describePrepared
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_text_decoder.c - PG::TextDecoder module
3
- * $Id: pg_text_decoder.c,v fcf731d3dff7 2015/09/08 12:25:06 jfali $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_text_encoder.c - PG::TextEncoder module
3
- * $Id: pg_text_encoder.c,v e61a06f1f5ed 2015/12/25 21:14:21 lars $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_column_map.c - PG::ColumnMap class extension
3
- * $Id: pg_type_map.c,v fcf731d3dff7 2015/09/08 12:25:06 jfali $
3
+ * $Id$
4
4
  *
5
5
  */
6
6
 
@@ -11,46 +11,53 @@ VALUE rb_mDefaultTypeMappable;
11
11
  static ID s_id_fit_to_query;
12
12
  static ID s_id_fit_to_result;
13
13
 
14
+ NORETURN( VALUE
15
+ pg_typemap_fit_to_result( VALUE self, VALUE result ));
16
+ NORETURN( VALUE
17
+ pg_typemap_fit_to_query( VALUE self, VALUE params ));
18
+ NORETURN( int
19
+ pg_typemap_fit_to_copy_get( VALUE self ));
20
+ NORETURN( VALUE
21
+ pg_typemap_result_value( t_typemap *p_typemap, VALUE result, int tuple, int field ));
22
+ NORETURN( t_pg_coder *
23
+ pg_typemap_typecast_query_param( t_typemap *p_typemap, VALUE param_value, int field ));
24
+ NORETURN( VALUE
25
+ pg_typemap_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, int format, int enc_idx ));
26
+
14
27
  VALUE
15
28
  pg_typemap_fit_to_result( VALUE self, VALUE result )
16
29
  {
17
30
  rb_raise( rb_eNotImpError, "type map %s is not suitable to map result values", rb_obj_classname(self) );
18
- return Qnil;
19
31
  }
20
32
 
21
33
  VALUE
22
34
  pg_typemap_fit_to_query( VALUE self, VALUE params )
23
35
  {
24
36
  rb_raise( rb_eNotImpError, "type map %s is not suitable to map query params", rb_obj_classname(self) );
25
- return Qnil;
26
37
  }
27
38
 
28
39
  int
29
40
  pg_typemap_fit_to_copy_get( VALUE self )
30
41
  {
31
42
  rb_raise( rb_eNotImpError, "type map %s is not suitable to map get_copy_data results", rb_obj_classname(self) );
32
- return Qnil;
33
43
  }
34
44
 
35
45
  VALUE
36
46
  pg_typemap_result_value( t_typemap *p_typemap, VALUE result, int tuple, int field )
37
47
  {
38
48
  rb_raise( rb_eNotImpError, "type map is not suitable to map result values" );
39
- return Qnil;
40
49
  }
41
50
 
42
51
  t_pg_coder *
43
52
  pg_typemap_typecast_query_param( t_typemap *p_typemap, VALUE param_value, int field )
44
53
  {
45
54
  rb_raise( rb_eNotImpError, "type map is not suitable to map query params" );
46
- return NULL;
47
55
  }
48
56
 
49
57
  VALUE
50
58
  pg_typemap_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, int format, int enc_idx )
51
59
  {
52
60
  rb_raise( rb_eNotImpError, "type map is not suitable to map get_copy_data results" );
53
- return Qnil;
54
61
  }
55
62
 
56
63
  const struct pg_typemap_funcs pg_typemap_funcs = {