diff --git a/ext/extconf.rb b/ext/extconf.rb index b36a4c3a8..d13634101 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -311,12 +311,6 @@ module PG "of this gem or upgrade your database to at least PostgreSQL-10." # optional headers/functions have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12 -have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14 - # Ensure header files fit as well - src + " int con(){ return PGRES_PIPELINE_SYNC; }" -end -have_func 'PQsetChunkedRowsMode', 'libpq-fe.h' # since PostgreSQL-17 -have_func 'PQfullProtocolVersion', 'libpq-fe.h' # since PostgreSQL-18 have_func 'timegm' have_func 'rb_io_wait' # since ruby-3.0 have_func 'rb_io_descriptor' # since ruby-3.1 diff --git a/ext/gvl_wrappers.c b/ext/gvl_wrappers.c index e472d778c..8e2f0ad86 100644 --- a/ext/gvl_wrappers.c +++ b/ext/gvl_wrappers.c @@ -6,7 +6,7 @@ #include "pg.h" -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE PGresult *PQclosePrepared(PGconn *conn, const char *stmtName){return NULL;} PGresult *PQclosePortal(PGconn *conn, const char *portalName){return NULL;} int PQsendClosePrepared(PGconn *conn, const char *stmtName){return 0;} @@ -16,7 +16,7 @@ int PQcancelBlocking(PGcancelConn *cancelConn){return 0;} int PQcancelStart(PGcancelConn *cancelConn){return 0;} PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn){return PGRES_POLLING_FAILED;} #endif -#ifndef HAVE_PQENTERPIPELINEMODE +#ifndef LIBPQ_HAS_PIPELINING int PQpipelineSync(PGconn *conn){return 0;} #endif diff --git a/ext/gvl_wrappers.h b/ext/gvl_wrappers.h index b3526d184..f048d7055 100644 --- a/ext/gvl_wrappers.h +++ b/ext/gvl_wrappers.h @@ -21,7 +21,7 @@ # include RUBY_EXTCONF_H #endif -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE typedef struct pg_cancel_conn PGcancelConn; #endif diff --git a/ext/pg.c b/ext/pg.c index db6d5cbfa..67969b1cd 100644 --- a/ext/pg.c +++ b/ext/pg.c @@ -508,12 +508,12 @@ Init_pg_ext(void) rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH)); /* Result#result_status constant - Single tuple from larger resultset. */ rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE)); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* Result#result_status constant - tuple chunk from larger resultset. */ rb_define_const(rb_mPGconstants, "PGRES_TUPLES_CHUNK", INT2FIX(PGRES_TUPLES_CHUNK)); #endif -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING /* Result#result_status constant - The PG::Result represents a synchronization point in pipeline mode, requested by Connection#pipeline_sync. * * This status occurs only when pipeline mode has been selected. */ @@ -643,7 +643,7 @@ Init_pg_ext(void) rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME)); #endif -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING /* Connection#pipeline_status constant * * The libpq connection is in pipeline mode. diff --git a/ext/pg_cancel_connection.c b/ext/pg_cancel_connection.c index cd479a805..dff2d047a 100644 --- a/ext/pg_cancel_connection.c +++ b/ext/pg_cancel_connection.c @@ -13,7 +13,7 @@ * */ -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE static VALUE rb_cPG_Cancon; static ID s_id_autoclose_set; @@ -340,7 +340,7 @@ pg_cancon_finish(VALUE self) void init_pg_cancon(void) { -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE s_id_autoclose_set = rb_intern("autoclose="); rb_cPG_Cancon = rb_define_class_under( rb_mPG, "CancelConnection", rb_cObject ); diff --git a/ext/pg_connection.c b/ext/pg_connection.c index 7bce51811..c8b71d67b 100644 --- a/ext/pg_connection.c +++ b/ext/pg_connection.c @@ -865,7 +865,7 @@ pgconn_protocol_version(VALUE self) return INT2NUM(protocol_version); } -#ifdef HAVE_PQFULLPROTOCOLVERSION +#ifdef LIBPQ_HAS_FULL_PROTOCOL_VERSION /* * call-seq: * conn.full_protocol_version -> Integer @@ -1038,7 +1038,7 @@ pgconn_backend_pid(VALUE self) return INT2NUM(PQbackendPID(pg_get_pgconn(self))); } -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE typedef struct { struct sockaddr_storage addr; @@ -1613,7 +1613,7 @@ pgconn_sync_describe_portal(VALUE self, VALUE stmt_name) } -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* * call-seq: * conn.sync_close_prepared( stmt_name ) -> PG::Result @@ -1917,7 +1917,7 @@ pgconn_set_single_row_mode(VALUE self) return self; } -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* * call-seq: * conn.set_chunked_rows_mode -> self @@ -2232,7 +2232,7 @@ pgconn_send_describe_portal(VALUE self, VALUE portal) "PQsendDescribePortal"); } -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* * call-seq: * conn.send_close_prepared( statement_name ) -> nil @@ -2358,7 +2358,7 @@ pgconn_sync_flush(VALUE self) return (ret) ? Qfalse : Qtrue; } -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE static VALUE pgconn_sync_cancel(VALUE self) { @@ -3657,7 +3657,7 @@ pgconn_async_describe_prepared(VALUE self, VALUE stmt_name) return pgconn_async_describe_close_prepared_potral(self, stmt_name, pgconn_send_describe_prepared); } -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* * call-seq: * conn.close_prepared( statement_name ) -> PG::Result @@ -3779,7 +3779,7 @@ pgconn_ssl_attribute_names(VALUE self) -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING /* * call-seq: * conn.pipeline_status -> Integer @@ -3872,7 +3872,7 @@ pgconn_sync_pipeline_sync(VALUE self) } -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE /* * call-seq: * conn.send_pipeline_sync -> nil @@ -4754,7 +4754,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "transaction_status", pgconn_transaction_status, 0); rb_define_method(rb_cPGconn, "parameter_status", pgconn_parameter_status, 1); rb_define_method(rb_cPGconn, "protocol_version", pgconn_protocol_version, 0); -#ifdef HAVE_PQFULLPROTOCOLVERSION +#ifdef LIBPQ_HAS_FULL_PROTOCOL_VERSION rb_define_method(rb_cPGconn, "full_protocol_version", pgconn_full_protocol_version, 0); #endif rb_define_method(rb_cPGconn, "server_version", pgconn_server_version, 0); @@ -4762,7 +4762,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "socket", pgconn_socket, 0); rb_define_method(rb_cPGconn, "socket_io", pgconn_socket_io, 0); rb_define_method(rb_cPGconn, "backend_pid", pgconn_backend_pid, 0); -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "backend_key", pgconn_backend_key, 0); #endif rb_define_method(rb_cPGconn, "connection_needs_password", pgconn_connection_needs_password, 0); @@ -4776,7 +4776,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "sync_exec_prepared", pgconn_sync_exec_prepared, -1); rb_define_method(rb_cPGconn, "sync_describe_prepared", pgconn_sync_describe_prepared, 1); rb_define_method(rb_cPGconn, "sync_describe_portal", pgconn_sync_describe_portal, 1); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "sync_close_prepared", pgconn_sync_close_prepared, 1); rb_define_method(rb_cPGconn, "sync_close_portal", pgconn_sync_close_portal, 1); #endif @@ -4787,7 +4787,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "exec_prepared", pgconn_async_exec_prepared, -1); rb_define_method(rb_cPGconn, "describe_prepared", pgconn_async_describe_prepared, 1); rb_define_method(rb_cPGconn, "describe_portal", pgconn_async_describe_portal, 1); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "close_prepared", pgconn_async_close_prepared, 1); rb_define_method(rb_cPGconn, "close_portal", pgconn_async_close_portal, 1); #endif @@ -4799,7 +4799,7 @@ init_pg_connection(void) rb_define_alias(rb_cPGconn, "async_exec_prepared", "exec_prepared"); rb_define_alias(rb_cPGconn, "async_describe_prepared", "describe_prepared"); rb_define_alias(rb_cPGconn, "async_describe_portal", "describe_portal"); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE rb_define_alias(rb_cPGconn, "async_close_prepared", "close_prepared"); rb_define_alias(rb_cPGconn, "async_close_portal", "close_portal"); #endif @@ -4812,7 +4812,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "escape_bytea", pgconn_s_escape_bytea, 1); rb_define_method(rb_cPGconn, "unescape_bytea", pgconn_s_unescape_bytea, 1); rb_define_method(rb_cPGconn, "set_single_row_mode", pgconn_set_single_row_mode, 0); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "set_chunked_rows_mode", pgconn_set_chunked_rows_mode, 1); #endif @@ -4834,7 +4834,7 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "discard_results", pgconn_discard_results, 0); /****** PG::Connection INSTANCE METHODS: Cancelling Queries in Progress ******/ -#ifndef HAVE_PQSETCHUNKEDROWSMODE +#ifndef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "sync_cancel", pgconn_sync_cancel, 0); #endif @@ -4876,13 +4876,13 @@ init_pg_connection(void) rb_define_method(rb_cPGconn, "ssl_attribute", pgconn_ssl_attribute, 1); rb_define_method(rb_cPGconn, "ssl_attribute_names", pgconn_ssl_attribute_names, 0); -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING rb_define_method(rb_cPGconn, "pipeline_status", pgconn_pipeline_status, 0); rb_define_method(rb_cPGconn, "enter_pipeline_mode", pgconn_enter_pipeline_mode, 0); rb_define_method(rb_cPGconn, "exit_pipeline_mode", pgconn_exit_pipeline_mode, 0); rb_define_method(rb_cPGconn, "sync_pipeline_sync", pgconn_sync_pipeline_sync, 0); rb_define_method(rb_cPGconn, "send_flush_request", pgconn_send_flush_request, 0); -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE rb_define_method(rb_cPGconn, "send_pipeline_sync", pgconn_send_pipeline_sync, 0); #endif #endif diff --git a/ext/pg_result.c b/ext/pg_result.c index 710b24f87..28420d176 100644 --- a/ext/pg_result.c +++ b/ext/pg_result.c @@ -315,17 +315,17 @@ pg_result_check( VALUE self ) case PGRES_SINGLE_TUPLE: case PGRES_EMPTY_QUERY: case PGRES_COMMAND_OK: -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING case PGRES_PIPELINE_SYNC: #endif -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE case PGRES_TUPLES_CHUNK: #endif return self; case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: case PGRES_NONFATAL_ERROR: -#ifdef HAVE_PQENTERPIPELINEMODE +#ifdef LIBPQ_HAS_PIPELINING case PGRES_PIPELINE_ABORTED: #endif error = rb_str_new2( PQresultErrorMessage(this->pgresult) ); @@ -1600,7 +1600,7 @@ pgresult_stream_any(VALUE self, int (*yielder)(VALUE, int, int, void*), void* da return self; rb_raise( rb_eInvalidResultStatus, "PG::Result is not in single row mode"); case PGRES_SINGLE_TUPLE: -#ifdef HAVE_PQSETCHUNKEDROWSMODE +#ifdef LIBPQ_HAS_CHUNK_MODE case PGRES_TUPLES_CHUNK: #endif break;