pg 0.21.0-x64-mingw32 → 1.0.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_column_map.c - PG::ColumnMap class extension
3
- * $Id$
3
+ * $Id: pg_binary_decoder.c,v fcf731d3dff7 2015/09/08 12:25:06 jfali $
4
4
  *
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_column_map.c - PG::ColumnMap class extension
3
- * $Id$
3
+ * $Id: pg_binary_encoder.c,v e61a06f1f5ed 2015/12/25 21:14:21 lars $
4
4
  *
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * pg_connection.c - PG::Connection class extension
3
- * $Id$
3
+ * $Id: pg_connection.c,v 1f0926bfa9a5 2018/01/04 18:14:32 lars $
4
4
  *
5
5
  */
6
6
 
@@ -18,19 +18,8 @@ static PQnoticeReceiver default_notice_receiver = NULL;
18
18
  static PQnoticeProcessor default_notice_processor = NULL;
19
19
 
20
20
  static VALUE pgconn_finish( VALUE );
21
- #ifdef M17N_SUPPORTED
22
21
  static VALUE pgconn_set_default_encoding( VALUE self );
23
22
  void pgconn_set_internal_encoding_index( VALUE );
24
- #endif
25
-
26
- #ifndef HAVE_RB_THREAD_FD_SELECT
27
- #define rb_fdset_t fd_set
28
- #define rb_fd_init(f)
29
- #define rb_fd_zero(f) FD_ZERO(f)
30
- #define rb_fd_set(n, f) FD_SET(n, f)
31
- #define rb_fd_term(f)
32
- #define rb_thread_fd_select rb_thread_select
33
- #endif
34
23
 
35
24
  /*
36
25
  * Global functions
@@ -95,7 +84,7 @@ pgconn_close_socket_io( VALUE self )
95
84
  VALUE socket_io = this->socket_io;
96
85
 
97
86
  if ( RTEST(socket_io) ) {
98
- #if defined(_WIN32) && defined(HAVE_RB_W32_WRAP_IO_HANDLE)
87
+ #if defined(_WIN32)
99
88
  int ruby_sd = NUM2INT(rb_funcall( socket_io, rb_intern("fileno"), 0 ));
100
89
  if( rb_w32_unwrap_io_handle(ruby_sd) ){
101
90
  rb_raise(rb_eConnectionBad, "Could not unwrap win32 socket handle");
@@ -291,9 +280,7 @@ pgconn_init(int argc, VALUE *argv, VALUE self)
291
280
  rb_exc_raise(error);
292
281
  }
293
282
 
294
- #ifdef M17N_SUPPORTED
295
283
  pgconn_set_default_encoding( self );
296
- #endif
297
284
 
298
285
  if (rb_block_given_p()) {
299
286
  return rb_ensure(rb_yield, self, pgconn_finish, self);
@@ -349,7 +336,6 @@ pgconn_s_connect_start( int argc, VALUE *argv, VALUE klass )
349
336
  return rb_conn;
350
337
  }
351
338
 
352
- #ifdef HAVE_PQPING
353
339
  /*
354
340
  * call-seq:
355
341
  * PG::Connection.ping(connection_hash) -> Integer
@@ -367,6 +353,8 @@ pgconn_s_connect_start( int argc, VALUE *argv, VALUE klass )
367
353
  * could not establish connection
368
354
  * [+PQPING_NO_ATTEMPT+]
369
355
  * connection not attempted (bad params)
356
+ *
357
+ * Available since PostgreSQL-9.1
370
358
  */
371
359
  static VALUE
372
360
  pgconn_s_ping( int argc, VALUE *argv, VALUE klass )
@@ -379,7 +367,6 @@ pgconn_s_ping( int argc, VALUE *argv, VALUE klass )
379
367
 
380
368
  return INT2FIX((int)ping);
381
369
  }
382
- #endif
383
370
 
384
371
 
385
372
  /*
@@ -418,16 +405,65 @@ pgconn_s_conndefaults(VALUE self)
418
405
  }
419
406
 
420
407
 
408
+ #ifdef HAVE_PQENCRYPTPASSWORDCONN
421
409
  /*
422
410
  * call-seq:
423
- * PG::Connection.encrypt_password( password, username ) -> String
411
+ * conn.encrypt_password( password, username, algorithm=nil ) -> String
412
+ *
413
+ * This function is intended to be used by client applications that wish to send commands like <tt>ALTER USER joe PASSWORD 'pwd'</tt>.
414
+ * It is good practice not to send the original cleartext password in such a command, because it might be exposed in command logs, activity displays, and so on.
415
+ * Instead, use this function to convert the password to encrypted form before it is sent.
424
416
  *
425
- * This function is intended to be used by client applications that
426
- * send commands like: +ALTER USER joe PASSWORD 'pwd'+.
427
- * The arguments are the cleartext password, and the SQL name
428
- * of the user it is for.
417
+ * The +password+ and +username+ arguments are the cleartext password, and the SQL name of the user it is for.
418
+ * +algorithm+ specifies the encryption algorithm to use to encrypt the password.
419
+ * Currently supported algorithms are +md5+ and +scram-sha-256+ (+on+ and +off+ are also accepted as aliases for +md5+, for compatibility with older server versions).
420
+ * Note that support for +scram-sha-256+ was introduced in PostgreSQL version 10, and will not work correctly with older server versions.
421
+ * If algorithm is omitted or +nil+, this function will query the server for the current value of the +password_encryption+ setting.
422
+ * That can block, and will fail if the current transaction is aborted, or if the connection is busy executing another query.
423
+ * If you wish to use the default algorithm for the server but want to avoid blocking, query +password_encryption+ yourself before calling #encrypt_password, and pass that value as the algorithm.
429
424
  *
430
425
  * Return value is the encrypted password.
426
+ * The caller can assume the string doesn't contain any special characters that would require escaping.
427
+ *
428
+ * Available since PostgreSQL-10
429
+ */
430
+ static VALUE
431
+ pgconn_encrypt_password(int argc, VALUE *argv, VALUE self)
432
+ {
433
+ char *encrypted = NULL;
434
+ VALUE rval = Qnil;
435
+ VALUE password, username, algorithm;
436
+ PGconn *conn = pg_get_pgconn(self);
437
+
438
+ rb_scan_args( argc, argv, "21", &password, &username, &algorithm );
439
+
440
+ Check_Type(password, T_STRING);
441
+ Check_Type(username, T_STRING);
442
+
443
+ encrypted = gvl_PQencryptPasswordConn(conn, StringValueCStr(password), StringValueCStr(username), RTEST(algorithm) ? StringValueCStr(algorithm) : NULL);
444
+ if ( encrypted ) {
445
+ rval = rb_str_new2( encrypted );
446
+ PQfreemem( encrypted );
447
+
448
+ OBJ_INFECT( rval, password );
449
+ OBJ_INFECT( rval, username );
450
+ OBJ_INFECT( rval, algorithm );
451
+ } else {
452
+ rb_raise(rb_ePGerror, "%s", PQerrorMessage(conn));
453
+ }
454
+
455
+ return rval;
456
+ }
457
+ #endif
458
+
459
+
460
+ /*
461
+ * call-seq:
462
+ * PG::Connection.encrypt_password( password, username ) -> String
463
+ *
464
+ * This is an older, deprecated version of #encrypt_password.
465
+ * The difference is that this function always uses +md5+ as the encryption algorithm.
466
+ *
431
467
  */
432
468
  static VALUE
433
469
  pgconn_s_encrypt_password(VALUE self, VALUE password, VALUE username)
@@ -613,7 +649,7 @@ pgconn_user(VALUE self)
613
649
  * call-seq:
614
650
  * conn.pass()
615
651
  *
616
- * Returns the authenticated user name.
652
+ * Returns the authenticated password.
617
653
  */
618
654
  static VALUE
619
655
  pgconn_pass(VALUE self)
@@ -686,6 +722,7 @@ pgconn_options(VALUE self)
686
722
  *
687
723
  * Returns the connection options used by a live connection.
688
724
  *
725
+ * Available since PostgreSQL-9.3
689
726
  */
690
727
  static VALUE
691
728
  pgconn_conninfo( VALUE self )
@@ -807,6 +844,8 @@ pgconn_error_message(VALUE self)
807
844
  * call-seq:
808
845
  * conn.socket() -> Integer
809
846
  *
847
+ * This method is deprecated. Please use the more portable method #socket_io .
848
+ *
810
849
  * Returns the socket's file descriptor for this connection.
811
850
  * <tt>IO.for_fd()</tt> can be used to build a proper IO object to the socket.
812
851
  * If you do so, you will likely also want to set <tt>autoclose=false</tt>
@@ -815,7 +854,7 @@ pgconn_error_message(VALUE self)
815
854
  * creates an IO that's associated with the connection object itself,
816
855
  * and so won't go out of scope until the connection does.
817
856
  *
818
- * *Note:* On Windows the file descriptor is not really usable,
857
+ * *Note:* On Windows the file descriptor is not usable,
819
858
  * since it can not be used to build a Ruby IO object.
820
859
  */
821
860
  static VALUE
@@ -827,22 +866,17 @@ pgconn_socket(VALUE self)
827
866
  return INT2NUM(sd);
828
867
  }
829
868
 
830
-
831
- #if !defined(_WIN32) || defined(HAVE_RB_W32_WRAP_IO_HANDLE)
832
-
833
869
  /*
834
870
  * call-seq:
835
871
  * conn.socket_io() -> IO
836
872
  *
837
- * Fetch a memoized IO object created from the Connection's underlying socket.
873
+ * Fetch a memorized IO object created from the Connection's underlying socket.
838
874
  * This object can be used for IO.select to wait for events while running
839
875
  * asynchronous API calls.
840
876
  *
841
877
  * Using this instead of #socket avoids the problem of the underlying connection
842
878
  * being closed by Ruby when an IO created using <tt>IO.for_fd(conn.socket)</tt>
843
- * goes out of scope.
844
- *
845
- * This method can also be used on Windows but requires Ruby-2.0+.
879
+ * goes out of scope. In contrast to #socket, it also works on Windows.
846
880
  */
847
881
  static VALUE
848
882
  pgconn_socket_io(VALUE self)
@@ -876,8 +910,6 @@ pgconn_socket_io(VALUE self)
876
910
  return socket_io;
877
911
  }
878
912
 
879
- #endif
880
-
881
913
  /*
882
914
  * call-seq:
883
915
  * conn.backend_pid() -> Integer
@@ -1254,7 +1286,7 @@ pgconn_query_assign_typemap( VALUE self, struct query_params_data *paramsData )
1254
1286
  * for binary.
1255
1287
  *
1256
1288
  * type_map can be a PG::TypeMap derivation (such as PG::BasicTypeMapForQueries).
1257
- * This will type cast the params form various Ruby types before transmission
1289
+ * This will type cast the params from various Ruby types before transmission
1258
1290
  * based on the encoders defined by the type map. When a type encoder is used
1259
1291
  * the format and oid of a given bind parameter are retrieved from the encoder
1260
1292
  * instead out of the hash form described above.
@@ -1390,7 +1422,7 @@ pgconn_prepare(int argc, VALUE *argv, VALUE self)
1390
1422
  * for binary.
1391
1423
  *
1392
1424
  * type_map can be a PG::TypeMap derivation (such as PG::BasicTypeMapForQueries).
1393
- * This will type cast the params form various Ruby types before transmission
1425
+ * This will type cast the params from various Ruby types before transmission
1394
1426
  * based on the encoders defined by the type map. When a type encoder is used
1395
1427
  * the format and oid of a given bind parameter are retrieved from the encoder
1396
1428
  * instead out of the hash form described above.
@@ -1646,12 +1678,13 @@ pgconn_s_unescape_bytea(VALUE self, VALUE str)
1646
1678
  return ret;
1647
1679
  }
1648
1680
 
1649
- #ifdef HAVE_PQESCAPELITERAL
1650
1681
  /*
1651
1682
  * call-seq:
1652
1683
  * conn.escape_literal( str ) -> String
1653
1684
  *
1654
1685
  * Escape an arbitrary String +str+ as a literal.
1686
+ *
1687
+ * Available since PostgreSQL-9.0
1655
1688
  */
1656
1689
  static VALUE
1657
1690
  pgconn_escape_literal(VALUE self, VALUE string)
@@ -1682,9 +1715,7 @@ pgconn_escape_literal(VALUE self, VALUE string)
1682
1715
 
1683
1716
  return result;
1684
1717
  }
1685
- #endif
1686
1718
 
1687
- #ifdef HAVE_PQESCAPEIDENTIFIER
1688
1719
  /*
1689
1720
  * call-seq:
1690
1721
  * conn.escape_identifier( str ) -> String
@@ -1694,6 +1725,8 @@ pgconn_escape_literal(VALUE self, VALUE string)
1694
1725
  * This method does the same as #quote_ident with a String argument,
1695
1726
  * but it doesn't support an Array argument and it makes use of libpq
1696
1727
  * to process the string.
1728
+ *
1729
+ * Available since PostgreSQL-9.0
1697
1730
  */
1698
1731
  static VALUE
1699
1732
  pgconn_escape_identifier(VALUE self, VALUE string)
@@ -1724,9 +1757,7 @@ pgconn_escape_identifier(VALUE self, VALUE string)
1724
1757
 
1725
1758
  return result;
1726
1759
  }
1727
- #endif
1728
1760
 
1729
- #ifdef HAVE_PQSETSINGLEROWMODE
1730
1761
  /*
1731
1762
  * call-seq:
1732
1763
  * conn.set_single_row_mode -> self
@@ -1763,6 +1794,7 @@ pgconn_escape_identifier(VALUE self, VALUE string)
1763
1794
  * end
1764
1795
  * end
1765
1796
  *
1797
+ * Available since PostgreSQL-9.2
1766
1798
  */
1767
1799
  static VALUE
1768
1800
  pgconn_set_single_row_mode(VALUE self)
@@ -1779,7 +1811,6 @@ pgconn_set_single_row_mode(VALUE self)
1779
1811
 
1780
1812
  return self;
1781
1813
  }
1782
- #endif
1783
1814
 
1784
1815
  /*
1785
1816
  * call-seq:
@@ -1813,7 +1844,7 @@ pgconn_set_single_row_mode(VALUE self)
1813
1844
  * for binary.
1814
1845
  *
1815
1846
  * type_map can be a PG::TypeMap derivation (such as PG::BasicTypeMapForQueries).
1816
- * This will type cast the params form various Ruby types before transmission
1847
+ * This will type cast the params from various Ruby types before transmission
1817
1848
  * based on the encoders defined by the type map. When a type encoder is used
1818
1849
  * the format and oid of a given bind parameter are retrieved from the encoder
1819
1850
  * instead out of the hash form described above.
@@ -1953,7 +1984,7 @@ pgconn_send_prepare(int argc, VALUE *argv, VALUE self)
1953
1984
  * for binary.
1954
1985
  *
1955
1986
  * type_map can be a PG::TypeMap derivation (such as PG::BasicTypeMapForQueries).
1956
- * This will type cast the params form various Ruby types before transmission
1987
+ * This will type cast the params from various Ruby types before transmission
1957
1988
  * based on the encoders defined by the type map. When a type encoder is used
1958
1989
  * the format and oid of a given bind parameter are retrieved from the encoder
1959
1990
  * instead out of the hash form described above.
@@ -2203,7 +2234,6 @@ pgconn_flush(self)
2203
2234
  static VALUE
2204
2235
  pgconn_cancel(VALUE self)
2205
2236
  {
2206
- #ifdef HAVE_PQGETCANCEL
2207
2237
  char errbuf[256];
2208
2238
  PGcancel *cancel;
2209
2239
  VALUE retval;
@@ -2221,9 +2251,6 @@ pgconn_cancel(VALUE self)
2221
2251
 
2222
2252
  PQfreeCancel(cancel);
2223
2253
  return retval;
2224
- #else
2225
- rb_notimplement();
2226
- #endif
2227
2254
  }
2228
2255
 
2229
2256
 
@@ -2267,45 +2294,8 @@ pgconn_notifies(VALUE self)
2267
2294
  return hash;
2268
2295
  }
2269
2296
 
2270
- /* Win32 + Ruby 1.8 */
2271
- #if !defined( HAVE_RUBY_VM_H ) && defined( _WIN32 )
2272
-
2273
- /*
2274
- * Duplicate the sockets from libpq and create temporary CRT FDs
2275
- */
2276
- void create_crt_fd(fd_set *os_set, fd_set *crt_set)
2277
- {
2278
- int i;
2279
- crt_set->fd_count = os_set->fd_count;
2280
- for (i = 0; i < os_set->fd_count; i++) {
2281
- WSAPROTOCOL_INFO wsa_pi;
2282
- /* dupicate the SOCKET */
2283
- int r = WSADuplicateSocket(os_set->fd_array[i], GetCurrentProcessId(), &wsa_pi);
2284
- SOCKET s = WSASocket(wsa_pi.iAddressFamily, wsa_pi.iSocketType, wsa_pi.iProtocol, &wsa_pi, 0, 0);
2285
- /* create the CRT fd so ruby can get back to the SOCKET */
2286
- int fd = _open_osfhandle(s, O_RDWR|O_BINARY);
2287
- os_set->fd_array[i] = s;
2288
- crt_set->fd_array[i] = fd;
2289
- }
2290
- }
2291
-
2292
- /*
2293
- * Clean up the CRT FDs from create_crt_fd()
2294
- */
2295
- void cleanup_crt_fd(fd_set *os_set, fd_set *crt_set)
2296
- {
2297
- int i;
2298
- for (i = 0; i < os_set->fd_count; i++) {
2299
- /* cleanup the CRT fd */
2300
- _close(crt_set->fd_array[i]);
2301
- /* cleanup the duplicated SOCKET */
2302
- closesocket(os_set->fd_array[i]);
2303
- }
2304
- }
2305
- #endif
2306
-
2307
2297
  /* Win32 + Ruby 1.9+ */
2308
- #if defined( HAVE_RUBY_VM_H ) && defined( _WIN32 )
2298
+ #if defined( _WIN32 )
2309
2299
  /*
2310
2300
  * On Windows, use platform-specific strategies to wait for the socket
2311
2301
  * instead of rb_thread_select().
@@ -2393,7 +2383,7 @@ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readabl
2393
2383
 
2394
2384
  #else
2395
2385
 
2396
- /* non Win32 or Win32+Ruby-1.8 */
2386
+ /* non Win32 */
2397
2387
 
2398
2388
  static void *
2399
2389
  wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readable)(PGconn *))
@@ -2403,9 +2393,6 @@ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readabl
2403
2393
  void *retval;
2404
2394
  rb_fdset_t sd_rset;
2405
2395
  struct timeval aborttime={0,0}, currtime, waittime;
2406
- #ifdef _WIN32
2407
- rb_fdset_t crt_sd_rset;
2408
- #endif
2409
2396
 
2410
2397
  if ( sd < 0 )
2411
2398
  rb_raise(rb_eConnectionBad, "PQsocket() can't get socket descriptor");
@@ -2425,14 +2412,6 @@ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readabl
2425
2412
  rb_fd_zero( &sd_rset );
2426
2413
  rb_fd_set( sd, &sd_rset );
2427
2414
 
2428
- #ifdef _WIN32
2429
- /* Ruby's FD_SET is modified on win32 to convert a file descriptor
2430
- * to osfhandle, but we already get a osfhandle from PQsocket().
2431
- * Therefore it's overwritten here. */
2432
- sd_rset.fd_array[0] = sd;
2433
- create_crt_fd(&sd_rset, &crt_sd_rset);
2434
- #endif
2435
-
2436
2415
  if ( ptimeout ) {
2437
2416
  gettimeofday(&currtime, NULL);
2438
2417
  timersub(&aborttime, &currtime, &waittime);
@@ -2446,11 +2425,6 @@ wait_socket_readable( PGconn *conn, struct timeval *ptimeout, void *(*is_readabl
2446
2425
  ret = 0;
2447
2426
  }
2448
2427
 
2449
-
2450
- #ifdef _WIN32
2451
- cleanup_crt_fd(&sd_rset, &crt_sd_rset);
2452
- #endif
2453
-
2454
2428
  if ( ret < 0 ){
2455
2429
  rb_fd_term( &sd_rset );
2456
2430
  rb_sys_fail( "rb_thread_select()" );
@@ -2528,12 +2502,10 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
2528
2502
  relname = rb_tainted_str_new2( pnotification->relname );
2529
2503
  PG_ENCODING_SET_NOCHECK( relname, ENCODING_GET(self) );
2530
2504
  be_pid = INT2NUM( pnotification->be_pid );
2531
- #ifdef HAVE_ST_NOTIFY_EXTRA
2532
2505
  if ( *pnotification->extra ) {
2533
2506
  extra = rb_tainted_str_new2( pnotification->extra );
2534
2507
  PG_ENCODING_SET_NOCHECK( extra, ENCODING_GET(self) );
2535
2508
  }
2536
- #endif
2537
2509
  PQfreemem( pnotification );
2538
2510
 
2539
2511
  if ( rb_block_given_p() )
@@ -2552,9 +2524,10 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
2552
2524
  * not sent (false is only possible if the connection
2553
2525
  * is in nonblocking mode, and this command would block).
2554
2526
  *
2555
- * encoder can be a PG::Coder derivation (typically PG::TextEncoder::CopyRow).
2556
- * This encodes the received data fields from an Array of Strings. Optionally
2557
- * the encoder can type cast the fields form various Ruby types in one step,
2527
+ * _encoder_ can be a PG::Coder derivation (typically PG::TextEncoder::CopyRow).
2528
+ * This encodes the data fields given as _buffer_ from an Array of Strings to
2529
+ * PostgreSQL's COPY text format inclusive proper escaping. Optionally
2530
+ * the encoder can type cast the fields from various Ruby types in one step,
2558
2531
  * if PG::TextEncoder::CopyRow#type_map is set accordingly.
2559
2532
  *
2560
2533
  * Raises an exception if an error occurs.
@@ -2665,8 +2638,9 @@ pgconn_put_copy_end(int argc, VALUE *argv, VALUE self)
2665
2638
  * if the copy is done, or +false+ if the call would
2666
2639
  * block (only possible if _async_ is true).
2667
2640
  *
2668
- * decoder can be a PG::Coder derivation (typically PG::TextDecoder::CopyRow).
2669
- * This decodes the received data fields as Array of Strings. Optionally
2641
+ * _decoder_ can be a PG::Coder derivation (typically PG::TextDecoder::CopyRow).
2642
+ * This decodes the received data fields from PostgreSQL's COPY text format to an
2643
+ * Array of Strings. Optionally
2670
2644
  * the decoder can type cast the fields to various Ruby types in one step,
2671
2645
  * if PG::TextDecoder::CopyRow#type_map is set accordingly.
2672
2646
  *
@@ -2968,11 +2942,9 @@ pgconn_set_client_encoding(VALUE self, VALUE str)
2968
2942
  Check_Type(str, T_STRING);
2969
2943
 
2970
2944
  if ( (gvl_PQsetClientEncoding(conn, StringValueCStr(str))) == -1 ) {
2971
- rb_raise(rb_ePGerror, "invalid encoding name: %s",StringValueCStr(str));
2945
+ rb_raise(rb_ePGerror, "%s", PQerrorMessage(conn));
2972
2946
  }
2973
- #ifdef M17N_SUPPORTED
2974
2947
  pgconn_set_internal_encoding_index( self );
2975
- #endif
2976
2948
 
2977
2949
  return Qnil;
2978
2950
  }
@@ -3198,14 +3170,13 @@ pgconn_async_exec(int argc, VALUE *argv, VALUE self)
3198
3170
 
3199
3171
 
3200
3172
  #ifdef HAVE_PQSSLATTRIBUTE
3201
- /* Since PostgreSQL-9.5: */
3202
-
3203
3173
  /*
3204
3174
  * call-seq:
3205
3175
  * conn.ssl_in_use? -> Boolean
3206
3176
  *
3207
3177
  * Returns +true+ if the connection uses SSL, +false+ if not.
3208
3178
  *
3179
+ * Available since PostgreSQL-9.5
3209
3180
  */
3210
3181
  static VALUE
3211
3182
  pgconn_ssl_in_use(VALUE self)
@@ -3238,6 +3209,8 @@ pgconn_ssl_in_use(VALUE self)
3238
3209
  *
3239
3210
  *
3240
3211
  * See also #ssl_attribute_names and http://www.postgresql.org/docs/current/interactive/libpq-status.html#LIBPQ-PQSSLATTRIBUTE
3212
+ *
3213
+ * Available since PostgreSQL-9.5
3241
3214
  */
3242
3215
  static VALUE
3243
3216
  pgconn_ssl_attribute(VALUE self, VALUE attribute_name)
@@ -3256,6 +3229,7 @@ pgconn_ssl_attribute(VALUE self, VALUE attribute_name)
3256
3229
  *
3257
3230
  * See also #ssl_attribute
3258
3231
  *
3232
+ * Available since PostgreSQL-9.5
3259
3233
  */
3260
3234
  static VALUE
3261
3235
  pgconn_ssl_attribute_names(VALUE self)
@@ -3566,8 +3540,6 @@ pgconn_lounlink(VALUE self, VALUE in_oid)
3566
3540
  }
3567
3541
 
3568
3542
 
3569
- #ifdef M17N_SUPPORTED
3570
-
3571
3543
  void
3572
3544
  pgconn_set_internal_encoding_index( VALUE self )
3573
3545
  {
@@ -3729,8 +3701,6 @@ pgconn_set_default_encoding( VALUE self )
3729
3701
  }
3730
3702
 
3731
3703
 
3732
- #endif /* M17N_SUPPORTED */
3733
-
3734
3704
  /*
3735
3705
  * call-seq:
3736
3706
  * res.type_map_for_queries = typemap
@@ -3939,9 +3909,7 @@ init_pg_connection()
3939
3909
  rb_define_singleton_method(rb_cPGconn, "quote_ident", pgconn_s_quote_ident, 1);
3940
3910
  rb_define_singleton_method(rb_cPGconn, "connect_start", pgconn_s_connect_start, -1);
3941
3911
  rb_define_singleton_method(rb_cPGconn, "conndefaults", pgconn_s_conndefaults, 0);
3942
- #ifdef HAVE_PQPING
3943
3912
  rb_define_singleton_method(rb_cPGconn, "ping", pgconn_s_ping, -1);
3944
- #endif
3945
3913
 
3946
3914
  /****** PG::Connection INSTANCE METHODS: Connection Control ******/
3947
3915
  rb_define_method(rb_cPGconn, "initialize", pgconn_init, -1);
@@ -3971,9 +3939,7 @@ init_pg_connection()
3971
3939
  rb_define_method(rb_cPGconn, "server_version", pgconn_server_version, 0);
3972
3940
  rb_define_method(rb_cPGconn, "error_message", pgconn_error_message, 0);
3973
3941
  rb_define_method(rb_cPGconn, "socket", pgconn_socket, 0);
3974
- #if !defined(_WIN32) || defined(HAVE_RB_W32_WRAP_IO_HANDLE)
3975
3942
  rb_define_method(rb_cPGconn, "socket_io", pgconn_socket_io, 0);
3976
- #endif
3977
3943
  rb_define_method(rb_cPGconn, "backend_pid", pgconn_backend_pid, 0);
3978
3944
  rb_define_method(rb_cPGconn, "connection_needs_password", pgconn_connection_needs_password, 0);
3979
3945
  rb_define_method(rb_cPGconn, "connection_used_password", pgconn_connection_used_password, 0);
@@ -3990,17 +3956,11 @@ init_pg_connection()
3990
3956
  rb_define_method(rb_cPGconn, "make_empty_pgresult", pgconn_make_empty_pgresult, 1);
3991
3957
  rb_define_method(rb_cPGconn, "escape_string", pgconn_s_escape, 1);
3992
3958
  rb_define_alias(rb_cPGconn, "escape", "escape_string");
3993
- #ifdef HAVE_PQESCAPELITERAL
3994
3959
  rb_define_method(rb_cPGconn, "escape_literal", pgconn_escape_literal, 1);
3995
- #endif
3996
- #ifdef HAVE_PQESCAPEIDENTIFIER
3997
3960
  rb_define_method(rb_cPGconn, "escape_identifier", pgconn_escape_identifier, 1);
3998
- #endif
3999
3961
  rb_define_method(rb_cPGconn, "escape_bytea", pgconn_s_escape_bytea, 1);
4000
3962
  rb_define_method(rb_cPGconn, "unescape_bytea", pgconn_s_unescape_bytea, 1);
4001
- #ifdef HAVE_PQSETSINGLEROWMODE
4002
3963
  rb_define_method(rb_cPGconn, "set_single_row_mode", pgconn_set_single_row_mode, 0);
4003
- #endif
4004
3964
 
4005
3965
  /****** PG::Connection INSTANCE METHODS: Asynchronous Command Processing ******/
4006
3966
  rb_define_method(rb_cPGconn, "send_query", pgconn_send_query, -1);
@@ -4048,6 +4008,9 @@ init_pg_connection()
4048
4008
  rb_define_method(rb_cPGconn, "async_exec", pgconn_async_exec, -1);
4049
4009
  rb_define_alias(rb_cPGconn, "async_query", "async_exec");
4050
4010
  rb_define_method(rb_cPGconn, "get_last_result", pgconn_get_last_result, 0);
4011
+ #ifdef HAVE_PQENCRYPTPASSWORDCONN
4012
+ rb_define_method(rb_cPGconn, "encrypt_password", pgconn_encrypt_password, -1);
4013
+ #endif
4051
4014
 
4052
4015
  #ifdef HAVE_PQSSLATTRIBUTE
4053
4016
  rb_define_method(rb_cPGconn, "ssl_in_use?", pgconn_ssl_in_use, 0);
@@ -4083,12 +4046,10 @@ init_pg_connection()
4083
4046
  rb_define_method(rb_cPGconn, "lo_unlink", pgconn_lounlink, 1);
4084
4047
  rb_define_alias(rb_cPGconn, "lounlink", "lo_unlink");
4085
4048
 
4086
- #ifdef M17N_SUPPORTED
4087
4049
  rb_define_method(rb_cPGconn, "internal_encoding", pgconn_internal_encoding, 0);
4088
4050
  rb_define_method(rb_cPGconn, "internal_encoding=", pgconn_internal_encoding_set, 1);
4089
4051
  rb_define_method(rb_cPGconn, "external_encoding", pgconn_external_encoding, 0);
4090
4052
  rb_define_method(rb_cPGconn, "set_default_encoding", pgconn_set_default_encoding, 0);
4091
- #endif /* M17N_SUPPORTED */
4092
4053
 
4093
4054
  rb_define_method(rb_cPGconn, "type_map_for_queries=", pgconn_type_map_for_queries_set, 1);
4094
4055
  rb_define_method(rb_cPGconn, "type_map_for_queries", pgconn_type_map_for_queries_get, 0);