Skip to content

Commit

Permalink
Merge pull request #547 from jackorp/fix_timestamp_conversion_for_x86
Browse files Browse the repository at this point in the history
Explicitly retype timespec fields to int64_t to fix compatibility with 32bit arches.
  • Loading branch information
larskanis authored Oct 20, 2023
2 parents 9c0e4de + 110665f commit 90879fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/pg_binary_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pg_bin_enc_timestamp(t_pg_coder *this, VALUE value, char *out, VALUE *intermedia
ts = rb_time_timespec(*intermediate);
/* PostgreSQL's timestamp is based on year 2000 and Ruby's time is based on 1970.
* Adjust the 30 years difference. */
timestamp = (ts.tv_sec - 10957L * 24L * 3600L) * 1000000 + (ts.tv_nsec / 1000);
timestamp = ((int64_t)ts.tv_sec - 10957L * 24L * 3600L) * 1000000 + ((int64_t)ts.tv_nsec / 1000);

if( this->flags & PG_CODER_TIMESTAMP_DB_LOCAL ) {
/* send as local time */
Expand Down

0 comments on commit 90879fa

Please sign in to comment.