Skip to content

Commit

Permalink
Fix compat with Truffleruby
Browse files Browse the repository at this point in the history
Truffleruby doesn't support rb_check_symbol_cstr() so far, but all symbols in Truffleruby are GC'd anyway.
So we can use classic ID2SYM to allocate the Symbol objects.

Discussed here: oracle/truffleruby#1814
  • Loading branch information
larskanis committed Nov 19, 2019
1 parent fd66f35 commit 330b4de
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/pg_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ static VALUE pg_cstr_to_sym(char *cstr, unsigned int flags, int enc_idx)
{
VALUE fname;
if( flags & PG_RESULT_FIELD_NAMES_SYMBOL ){
#ifndef TRUFFLERUBY
rb_encoding *enc = rb_enc_from_index(enc_idx);
fname = rb_check_symbol_cstr(cstr, strlen(cstr), enc);
if( fname == Qnil ){
Expand All @@ -418,6 +419,7 @@ static VALUE pg_cstr_to_sym(char *cstr, unsigned int flags, int enc_idx)
fname = rb_str_intern(fname);
}
} else if( flags & PG_RESULT_FIELD_NAMES_STATIC_SYMBOL ){
#endif
rb_encoding *enc = rb_enc_from_index(enc_idx);
fname = ID2SYM(rb_intern3(cstr, strlen(cstr), enc));
} else {
Expand Down

0 comments on commit 330b4de

Please sign in to comment.