From b99f1197b8b72add8c597666fe1437d1edd8df5a Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 17 Oct 2026 15:21:01 +0200 Subject: [PATCH 1/3] Update git hash for postgres' syntax.sgml --- spec/pg/connection_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb index 2444a6aef..05e373e89 100644 --- a/spec/pg/connection_spec.rb +++ b/spec/pg/connection_spec.rb @@ -3088,7 +3088,7 @@ def with_std_conf_strings(conn, onoff) skip "github API access failed: #{latest_commit_info[:message]}" if latest_commit_info.is_a?(Hash) && latest_commit_info[:message] expect(latest_commit_info).to be_kind_of(Array), latest_commit_info.to_s expect(latest_commit_info[0]).to be_kind_of(Hash), latest_commit_info.to_s - expect(latest_commit_info[0][:sha]).to eq("45762084545ec14dbbe66ace1d69d7e89f8978ac"), error_message + expect(latest_commit_info[0][:sha]).to eq("0a38a8ff3fb560ec9302cf06616ab4a4e6027c40"), error_message rescue SocketError, JSON::ParserError => err skip "cannot access PostgreSQL git repository: #{err}" end From c2127e1179f19b32b8b9dca687787af3f4a298bd Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 17 Oct 2026 15:12:54 +0200 Subject: [PATCH 2/3] Make use of new data type for lengths in ruby-4.1+ See discussion in: https://bugs.ruby-lang.org/issues/22400 --- ext/pg.h | 5 +++++ ext/pg_binary_decoder.c | 4 ++-- ext/pg_copy_coder.c | 6 +++--- ext/pg_record_coder.c | 2 +- ext/pg_text_decoder.c | 2 +- ext/pg_text_encoder.c | 6 +++--- ext/pg_tuple.c | 2 +- ext/pg_type_map_by_class.c | 2 +- ext/pg_type_map_by_column.c | 2 +- ext/pg_util.c | 16 ++++++++-------- 10 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ext/pg.h b/ext/pg.h index aa8a9c679..65d5fe4ce 100644 --- a/ext/pg.h +++ b/ext/pg.h @@ -80,6 +80,11 @@ typedef long suseconds_t; #define rb_hash_new_capa(x) rb_hash_new() #endif +#ifndef HAVE_RB_LEN_T +typedef long rb_len_t; +typedef unsigned long rb_ulen_t; +#endif + #define pg_gc_location(x) x = rb_gc_location(x) extern int ruby_native_thread_p(void); diff --git a/ext/pg_binary_decoder.c b/ext/pg_binary_decoder.c index d2166aef4..56d9cb7f4 100644 --- a/ext/pg_binary_decoder.c +++ b/ext/pg_binary_decoder.c @@ -275,12 +275,12 @@ pg_bin_dec_array(t_pg_coder *conv, const char *input_line, int len, int tuple, i } if (cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after binary array data at position: %ld", (long)(cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after binary array data at position: %td", (cur_ptr - input_line) + 1 ); return arrays[0]; length_error: - rb_raise( rb_eArgError, "premature end of binary array data at position: %ld", (long)(cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "premature end of binary array data at position: %td", (cur_ptr - input_line) + 1 ); } #define PG_INT64_MIN (-0x7FFFFFFFFFFFFFFFL - 1) diff --git a/ext/pg_copy_coder.c b/ext/pg_copy_coder.c index c74986dc1..e1118e104 100644 --- a/ext/pg_copy_coder.c +++ b/ext/pg_copy_coder.c @@ -692,7 +692,7 @@ pg_text_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tup } if (!found_delim && cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after linefeed at position: %ld", (long)(cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after linefeed at position: %td", (cur_ptr - input_line) + 1 ); /* Check whether raw input matched null marker */ @@ -881,13 +881,13 @@ pg_bin_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tupl } if (cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after row data at position: %ld", (long)(cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after row data at position: %td", (cur_ptr - input_line) + 1 ); RB_GC_GUARD(rb_typemap); return array; length_error: - rb_raise( rb_eArgError, "premature end of COPY data at position: %ld", (long)(cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "premature end of COPY data at position: %td", (cur_ptr - input_line) + 1 ); } void diff --git a/ext/pg_record_coder.c b/ext/pg_record_coder.c index 2b55707e8..9171d59f4 100644 --- a/ext/pg_record_coder.c +++ b/ext/pg_record_coder.c @@ -198,7 +198,7 @@ pg_text_enc_record(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate for( i=0; i= 8 && FIXNUM_MAX >= 1000000000000000000LL ){ diff --git a/ext/pg_text_encoder.c b/ext/pg_text_encoder.c index f131d0fea..61f28ab49 100644 --- a/ext/pg_text_encoder.c +++ b/ext/pg_text_encoder.c @@ -430,7 +430,7 @@ pg_text_enc_bytea(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, } return (int)(optr - out); }else{ - long size; + rb_len_t size; *intermediate = rb_obj_as_string(value); size = RSTRING_LEN(*intermediate); @@ -653,8 +653,8 @@ quote_identifier( VALUE value, VALUE out_string, char *current_out ){ static char * pg_text_enc_array_identifier(VALUE value, VALUE string, char *out, int enc_idx) { - long i; - long nr_elems; + rb_len_t i; + rb_len_t nr_elems; Check_Type(value, T_ARRAY); nr_elems = RARRAY_LEN(value); diff --git a/ext/pg_tuple.c b/ext/pg_tuple.c index be2ed9a24..07ddd2fb5 100644 --- a/ext/pg_tuple.c +++ b/ext/pg_tuple.c @@ -253,7 +253,7 @@ static VALUE pg_tuple_fetch(int argc, VALUE *argv, VALUE self) { VALUE key; - long block_given; + int block_given; VALUE index; int field_num; t_pg_tuple *this = pg_tuple_get_this(self); diff --git a/ext/pg_type_map_by_class.c b/ext/pg_type_map_by_class.c index 01759db32..051cd1ba5 100644 --- a/ext/pg_type_map_by_class.c +++ b/ext/pg_type_map_by_class.c @@ -27,7 +27,7 @@ typedef struct { * We use 8 Bits of the klass object id as index to a 256 entry cache. * This avoids full lookups in most cases. */ -#define CACHE_LOOKUP(this, klass) ( &this->cache_row[(((unsigned long)klass) >> 8) & 0xff] ) +#define CACHE_LOOKUP(this, klass) ( &this->cache_row[(((unsigned int)klass) >> 8) & 0xff] ) static t_pg_coder * diff --git a/ext/pg_type_map_by_column.c b/ext/pg_type_map_by_column.c index c3c42a5e8..37d3fbbcd 100644 --- a/ext/pg_type_map_by_column.c +++ b/ext/pg_type_map_by_column.c @@ -263,7 +263,7 @@ pg_tmbc_allocate(void) static VALUE pg_tmbc_init(VALUE self, VALUE conv_ary) { - long i; + int i; t_tmbc *this; int conv_ary_len; diff --git a/ext/pg_util.c b/ext/pg_util.c index 572aa8db8..a52241db1 100644 --- a/ext/pg_util.c +++ b/ext/pg_util.c @@ -22,10 +22,10 @@ rbpg_base64_encode( char *out, const char *in, int len) int part_len = len % 3; if( part_len > 0 ){ - long byte2 = 0; - long byte1 = part_len > 1 ? *--in_ptr : 0; - long byte0 = *--in_ptr; - long triple = (byte0 << 16) + (byte1 << 8) + byte2; + int byte2 = 0; + int byte1 = part_len > 1 ? *--in_ptr : 0; + int byte0 = *--in_ptr; + int triple = (byte0 << 16) + (byte1 << 8) + byte2; *--out_ptr = '='; *--out_ptr = part_len > 1 ? base64_encode_table[(triple >> 1 * 6) & 0x3F] : '='; @@ -34,10 +34,10 @@ rbpg_base64_encode( char *out, const char *in, int len) } while( out_ptr > out ){ - long byte2 = *--in_ptr; - long byte1 = *--in_ptr; - long byte0 = *--in_ptr; - long triple = (byte0 << 16) + (byte1 << 8) + byte2; + int byte2 = *--in_ptr; + int byte1 = *--in_ptr; + int byte0 = *--in_ptr; + int triple = (byte0 << 16) + (byte1 << 8) + byte2; *--out_ptr = base64_encode_table[(triple >> 0 * 6) & 0x3F]; *--out_ptr = base64_encode_table[(triple >> 1 * 6) & 0x3F]; From af41d2fa8b0c31feb51d61af169795e45cac8f41 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 17 Oct 2026 22:38:19 +0200 Subject: [PATCH 3/3] Use printf format %lld instead of %td because of Truffleruby Truffleruby fails to print %td at runtime with: expected ArgumentError with message matching /trailing data.*at position: 7$/, got # with backtrace: /home/runner/.rubies/truffleruby-head/lib/truffle/truffle/cext.rb:1369:in 'Truffle::CExt#rb_exc_raise' /home/runner/.rubies/truffleruby-head/lib/truffle/truffle/cext_ruby.rb:83:in 'PG::BinaryDecoder::CopyRow#decode' ./spec/pg/type_spec.rb:1574:in 'block (7 levels) in ' ./spec/pg/type_spec.rb:1574:in 'block (6 levels) in ' ./spec/helpers.rb:64:in 'block in PG::TestingHelpers.included' /home/runner/.rubies/truffleruby-head/lib/mri/rubygems.rb:304:in 'Gem.activate_and_load_bin_path' ./spec/pg/type_spec.rb:1574:in 'block (6 levels) in ' ./spec/helpers.rb:64:in 'block in PG::TestingHelpers.included' --- ext/pg_binary_decoder.c | 4 ++-- ext/pg_copy_coder.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/pg_binary_decoder.c b/ext/pg_binary_decoder.c index 56d9cb7f4..0e299e484 100644 --- a/ext/pg_binary_decoder.c +++ b/ext/pg_binary_decoder.c @@ -275,12 +275,12 @@ pg_bin_dec_array(t_pg_coder *conv, const char *input_line, int len, int tuple, i } if (cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after binary array data at position: %td", (cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after binary array data at position: %lld", (long long)(cur_ptr - input_line) + 1 ); return arrays[0]; length_error: - rb_raise( rb_eArgError, "premature end of binary array data at position: %td", (cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "premature end of binary array data at position: %lld", (long long)(cur_ptr - input_line) + 1 ); } #define PG_INT64_MIN (-0x7FFFFFFFFFFFFFFFL - 1) diff --git a/ext/pg_copy_coder.c b/ext/pg_copy_coder.c index e1118e104..99daef3bb 100644 --- a/ext/pg_copy_coder.c +++ b/ext/pg_copy_coder.c @@ -692,7 +692,7 @@ pg_text_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tup } if (!found_delim && cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after linefeed at position: %td", (cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after linefeed at position: %lld", (long long)(cur_ptr - input_line) + 1 ); /* Check whether raw input matched null marker */ @@ -881,13 +881,13 @@ pg_bin_dec_copy_row(t_pg_coder *conv, const char *input_line, int len, int _tupl } if (cur_ptr < line_end_ptr) - rb_raise( rb_eArgError, "trailing data after row data at position: %td", (cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "trailing data after row data at position: %lld", (long long)(cur_ptr - input_line) + 1 ); RB_GC_GUARD(rb_typemap); return array; length_error: - rb_raise( rb_eArgError, "premature end of COPY data at position: %td", (cur_ptr - input_line) + 1 ); + rb_raise( rb_eArgError, "premature end of COPY data at position: %lld", (long long)(cur_ptr - input_line) + 1 ); } void