Skip to content

Commit

Permalink
Remove support for PostgreSQL versions prior 9.2
Browse files Browse the repository at this point in the history
This makes installation faster due to less tests for libpq functions.
  • Loading branch information
larskanis committed Jan 3, 2018
1 parent 6c482d0 commit c016756
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 655 deletions.
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docs :: http://deveiate.org/code/pg

Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].

It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].

A small example usage:

Expand All @@ -38,7 +38,7 @@ A small example usage:
== Requirements

* Ruby 2.2 or newer
* PostgreSQL 9.1.x or later (with headers, -dev packages, etc).
* PostgreSQL 9.2.x or later (with headers, -dev packages, etc).

It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
not regularly tested.
Expand Down
24 changes: 2 additions & 22 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,9 @@
end

# optional headers/functions
have_func 'PQconnectionUsedPassword' or
have_func 'PQsetSingleRowMode' or
abort "Your PostgreSQL is too old. Either install an older version " +
"of this gem or upgrade your database."
have_func 'PQisthreadsafe'
have_func 'PQprepare'
have_func 'PQexecParams'
have_func 'PQescapeString'
have_func 'PQescapeStringConn'
have_func 'PQescapeLiteral'
have_func 'PQescapeIdentifier'
have_func 'PQgetCancel'
have_func 'lo_create'
have_func 'pg_encoding_to_char'
have_func 'pg_char_to_encoding'
have_func 'PQsetClientEncoding'
have_func 'PQlibVersion'
have_func 'PQping'
have_func 'PQsetSingleRowMode'
"of this gem or upgrade your database to at least PostgreSQL-9.2."
have_func 'PQconninfo'
have_func 'PQsslAttribute'
have_func 'PQencryptPasswordConn'
Expand All @@ -101,13 +86,8 @@
have_func 'rb_str_modify_expand'
have_func 'rb_hash_dup'

have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'

$defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'

# unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
have_header 'unistd.h'
have_header 'inttypes.h'
Expand Down
10 changes: 0 additions & 10 deletions ext/pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
* Module Methods
**************************************************************************/

#ifdef HAVE_PQLIBVERSION
/*
* call-seq:
* PG.library_version -> Integer
Expand All @@ -316,7 +315,6 @@ pg_s_library_version(VALUE self)
UNUSED( self );
return INT2NUM(PQlibVersion());
}
#endif


/*
Expand Down Expand Up @@ -410,9 +408,7 @@ Init_pg_ext()
/*************************
* PG module methods
*************************/
#ifdef HAVE_PQLIBVERSION
rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
#endif
rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
Expand Down Expand Up @@ -478,7 +474,6 @@ Init_pg_ext()
/* Verbose error verbosity level (#set_error_verbosity) */
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));

#ifdef HAVE_PQPING
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/

/* Server is accepting connections. */
Expand All @@ -489,7 +484,6 @@ Init_pg_ext()
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
/* Connection not attempted (bad params). */
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
#endif

/****** PG::Connection CLASS CONSTANTS: Large Objects ******/

Expand Down Expand Up @@ -524,13 +518,9 @@ Init_pg_ext()
/* #result_status constant: A fatal error occurred. */
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
/* #result_status constant: Copy In/Out data transfer in progress. */
#ifdef HAVE_CONST_PGRES_COPY_BOTH
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
#endif
/* #result_status constant: Single tuple from larger resultset. */
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
#endif

/****** Result CONSTANTS: result error field codes ******/

Expand Down
22 changes: 0 additions & 22 deletions ext/pg_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ pgconn_s_connect_start( int argc, VALUE *argv, VALUE klass )
return rb_conn;
}

#ifdef HAVE_PQPING
/*
* call-seq:
* PG::Connection.ping(connection_hash) -> Integer
Expand Down Expand Up @@ -381,7 +380,6 @@ pgconn_s_ping( int argc, VALUE *argv, VALUE klass )

return INT2FIX((int)ping);
}
#endif


/*
Expand Down Expand Up @@ -1698,7 +1696,6 @@ pgconn_s_unescape_bytea(VALUE self, VALUE str)
return ret;
}

#ifdef HAVE_PQESCAPELITERAL
/*
* call-seq:
* conn.escape_literal( str ) -> String
Expand Down Expand Up @@ -1736,9 +1733,7 @@ pgconn_escape_literal(VALUE self, VALUE string)

return result;
}
#endif

#ifdef HAVE_PQESCAPEIDENTIFIER
/*
* call-seq:
* conn.escape_identifier( str ) -> String
Expand Down Expand Up @@ -1780,9 +1775,7 @@ pgconn_escape_identifier(VALUE self, VALUE string)

return result;
}
#endif

#ifdef HAVE_PQSETSINGLEROWMODE
/*
* call-seq:
* conn.set_single_row_mode -> self
Expand Down Expand Up @@ -1836,7 +1829,6 @@ pgconn_set_single_row_mode(VALUE self)

return self;
}
#endif

/*
* call-seq:
Expand Down Expand Up @@ -2260,7 +2252,6 @@ pgconn_flush(self)
static VALUE
pgconn_cancel(VALUE self)
{
#ifdef HAVE_PQGETCANCEL
char errbuf[256];
PGcancel *cancel;
VALUE retval;
Expand All @@ -2278,9 +2269,6 @@ pgconn_cancel(VALUE self)

PQfreeCancel(cancel);
return retval;
#else
rb_notimplement();
#endif
}


Expand Down Expand Up @@ -2585,12 +2573,10 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
relname = rb_tainted_str_new2( pnotification->relname );
PG_ENCODING_SET_NOCHECK( relname, ENCODING_GET(self) );
be_pid = INT2NUM( pnotification->be_pid );
#ifdef HAVE_ST_NOTIFY_EXTRA
if ( *pnotification->extra ) {
extra = rb_tainted_str_new2( pnotification->extra );
PG_ENCODING_SET_NOCHECK( extra, ENCODING_GET(self) );
}
#endif
PQfreemem( pnotification );

if ( rb_block_given_p() )
Expand Down Expand Up @@ -4000,9 +3986,7 @@ init_pg_connection()
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_PQPING
rb_define_singleton_method(rb_cPGconn, "ping", pgconn_s_ping, -1);
#endif

/****** PG::Connection INSTANCE METHODS: Connection Control ******/
rb_define_method(rb_cPGconn, "initialize", pgconn_init, -1);
Expand Down Expand Up @@ -4051,17 +4035,11 @@ init_pg_connection()
rb_define_method(rb_cPGconn, "make_empty_pgresult", pgconn_make_empty_pgresult, 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_escape_literal, 1);
#endif
#ifdef HAVE_PQESCAPEIDENTIFIER
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);
#ifdef HAVE_PQSETSINGLEROWMODE
rb_define_method(rb_cPGconn, "set_single_row_mode", pgconn_set_single_row_mode, 0);
#endif

/****** PG::Connection INSTANCE METHODS: Asynchronous Command Processing ******/
rb_define_method(rb_cPGconn, "send_query", pgconn_send_query, -1);
Expand Down
8 changes: 0 additions & 8 deletions ext/pg_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@ pg_result_check( VALUE self )
case PGRES_TUPLES_OK:
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
#ifdef HAVE_CONST_PGRES_COPY_BOTH
case PGRES_COPY_BOTH:
#endif
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
case PGRES_SINGLE_TUPLE:
#endif
case PGRES_EMPTY_QUERY:
case PGRES_COMMAND_OK:
return self;
Expand Down Expand Up @@ -1056,7 +1052,6 @@ pgresult_type_map_get(VALUE self)
return this->typemap;
}

#ifdef HAVE_PQSETSINGLEROWMODE
/*
* call-seq:
* res.stream_each{ |tuple| ... }
Expand Down Expand Up @@ -1214,7 +1209,6 @@ pgresult_stream_each_row(VALUE self)
/* never reached */
return self;
}
#endif


void
Expand Down Expand Up @@ -1271,11 +1265,9 @@ init_pg_result()
rb_define_method(rb_cPGresult, "type_map=", pgresult_type_map_set, 1);
rb_define_method(rb_cPGresult, "type_map", pgresult_type_map_get, 0);

#ifdef HAVE_PQSETSINGLEROWMODE
/****** PG::Result INSTANCE METHODS: streaming ******/
rb_define_method(rb_cPGresult, "stream_each", pgresult_stream_each, 0);
rb_define_method(rb_cPGresult, "stream_each_row", pgresult_stream_each_row, 0);
#endif
}


Loading

0 comments on commit c016756

Please sign in to comment.