Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ext/pg_binary_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: %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: %ld", (long)(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)
Expand Down
6 changes: 3 additions & 3 deletions ext/pg_copy_coder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: %lld", (long long)(cur_ptr - input_line) + 1 );


/* Check whether raw input matched null marker */
Expand Down Expand Up @@ -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: %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: %ld", (long)(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
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_record_coder.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pg_text_enc_record(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate
for( i=0; i<RARRAY_LEN(value); i++){
char *ptr1;
char *ptr2;
long strlen;
rb_len_t strlen;
int backslashes;
VALUE subint;
VALUE entry;
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_text_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pg_text_dec_string(t_pg_coder *conv, const char *val, int len, int tuple, int fi
static VALUE
pg_text_dec_integer(t_pg_coder *conv, const char *val, int len, int tuple, int field, int enc_idx)
{
long i;
rb_len_t i;
int max_len;

if( sizeof(i) >= 8 && FIXNUM_MAX >= 1000000000000000000LL ){
Expand Down
6 changes: 3 additions & 3 deletions ext/pg_text_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_tuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_type_map_by_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_type_map_by_column.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 8 additions & 8 deletions ext/pg_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] : '=';
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion spec/pg/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading