Commits

Kashif Rasul committed f82d969

Added library_version() as a singleton method. Removed non-singletons.

  • Participants
  • Parent commits fd22651
  • Branches issue-68

Comments (0)

Files changed (2)

 have_func 'pg_encoding_to_char'
 have_func 'pg_char_to_encoding'
 have_func 'PQsetClientEncoding'
+have_func 'PQlibVersion'
 
 have_func 'rb_encdb_alias'
 have_func 'rb_enc_alias'

ext/pg_connection.c

 	return INT2NUM(PQprotocolVersion(pg_get_pgconn(self)));
 }
 
+#ifdef HAVE_PQLIBVERSION
+/*
+ * call-seq:
+ *   PG::Connection.library_version -> Integer
+ *
+ * Get the version of the libpq library in use.
+ */
+static VALUE
+pgconn_s_library_version(VALUE self)
+{
+	return INT2NUM(PQlibVersion());
+}
+#endif
+
 /* 
  * call-seq: 
  *   conn.server_version -> Integer
  * Escape an arbitrary String _str_ as a literal.
  */
 static VALUE
-pgconn_s_escape_literal(VALUE self, VALUE string)
+pgconn_escape_literal(VALUE self, VALUE string)
 {
 	PGconn *conn = pg_get_pgconn(self);
 	char *escaped = NULL;
  * Escape an arbitrary String _str_ as an identifier.
  */
 static VALUE
-pgconn_s_escape_identifier(VALUE self, VALUE string)
+pgconn_escape_identifier(VALUE self, VALUE string)
 {
 	PGconn *conn = pg_get_pgconn(self);
 	char *escaped = NULL;
 	SINGLETON_ALIAS(rb_cPGconn, "setdblogin", "new");
 	rb_define_singleton_method(rb_cPGconn, "escape_string", pgconn_s_escape, 1);
 	SINGLETON_ALIAS(rb_cPGconn, "escape", "escape_string");
-#ifdef HAVE_PQESCAPELITERAL
-	rb_define_singleton_method(rb_cPGconn, "escape_literal", pgconn_s_escape_literal, 1);
-#endif
-#ifdef HAVE_PQESCAPEIDENTIFIER
-	rb_define_singleton_method(rb_cPGconn, "escape_identifier", pgconn_s_escape_identifier, 1);
-#endif
 	rb_define_singleton_method(rb_cPGconn, "escape_bytea", pgconn_s_escape_bytea, 1);
 	rb_define_singleton_method(rb_cPGconn, "unescape_bytea", pgconn_s_unescape_bytea, 1);
 	rb_define_singleton_method(rb_cPGconn, "isthreadsafe", pgconn_s_isthreadsafe, 0);
 	rb_define_singleton_method(rb_cPGconn, "quote_ident", pgconn_s_quote_ident, 1);
 	rb_define_singleton_method(rb_cPGconn, "connect_start", pgconn_s_connect_start, -1);
 	rb_define_singleton_method(rb_cPGconn, "conndefaults", pgconn_s_conndefaults, 0);
+#ifdef HAVE_PQLIBVERSION
+	rb_define_singleton_method(rb_cPGconn, "library_version", pgconn_s_library_version, 0);
+#endif
 
 	/******     PG::Connection INSTANCE METHODS: Connection Control     ******/
 	rb_define_method(rb_cPGconn, "initialize", pgconn_init, -1);
 	rb_define_method(rb_cPGconn, "escape_string", pgconn_s_escape, 1);
 	rb_define_alias(rb_cPGconn, "escape", "escape_string");
 #ifdef HAVE_PQESCAPELITERAL
-	rb_define_method(rb_cPGconn, "escape_literal", pgconn_s_escape_literal, 1);
+	rb_define_method(rb_cPGconn, "escape_literal", pgconn_escape_literal, 1);
 #endif
 #ifdef HAVE_PQESCAPEIDENTIFIER
-	rb_define_method(rb_cPGconn, "escape_identifier", pgconn_s_escape_identifier, 1);
+	rb_define_method(rb_cPGconn, "escape_identifier", pgconn_escape_identifier, 1);
 #endif
 	rb_define_method(rb_cPGconn, "escape_bytea", pgconn_s_escape_bytea, 1);
 	rb_define_method(rb_cPGconn, "unescape_bytea", pgconn_s_unescape_bytea, 1);