-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encode column names with encoding of context #210
base: main
Are you sure you want to change the base?
Changes from 1 commit
9ca5024
9343cd4
b55afcf
70410b8
88d6be0
f84264c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -811,10 +811,12 @@ static VALUE read_query_response(VALUE vargs) | |
} | ||
} | ||
|
||
rb_encoding *conn_enc = rb_to_encoding(ctx->encoding); | ||
|
||
#ifdef HAVE_RB_INTERNED_STR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be updated to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I changed this to use |
||
VALUE column_name = rb_interned_str(column.name, column.name_len); | ||
VALUE column_name = rb_enc_interned_str(column.name, column.name_len, conn_enc); | ||
#else | ||
VALUE column_name = rb_str_new(column.name, column.name_len); | ||
VALUE column_name = rb_enc_str_new(column.name, column.name_len, conn_enc); | ||
OBJ_FREEZE(column_name); | ||
#endif | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rb_to_encoding
is quite costly. We probably should it only once after connect or something, and keep arb_encoding *
inctx
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least, it should be moved outside the loop, so that if you have 20 fields you don't do the conversion 20 times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I moved the call to
rb_to_encoding
to therb_trilogy_connect
method and store it inrb_encoding *conn_encoding
in thectx
. I also replaced the call to therb_to_encoding
method inrb_trilogy_query
to use this value in thectx
struct. Let me know if you'd need any other adaptions for this.