mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 19:03:43 +03:00
Make sure to use 64 bits in interval parsing accumulators
This commit is contained in:
parent
834e9996da
commit
3b665d35d5
|
@ -220,10 +220,9 @@ typecast_PYTIME_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
||||||
{
|
{
|
||||||
long years = 0, months = 0, days = 0;
|
long v = 0, years = 0, months = 0, hours = 0, minutes = 0, micros = 0;
|
||||||
long hours = 0, minutes = 0, seconds = 0, micros = 0;
|
PY_LONG_LONG days = 0, seconds = 0;
|
||||||
long v = 0, sign = 1, denom = 1;
|
int sign = 1, denom = 1, part = 0;
|
||||||
int part = 0;
|
|
||||||
|
|
||||||
if (str == NULL) { Py_RETURN_NONE; }
|
if (str == NULL) { Py_RETURN_NONE; }
|
||||||
|
|
||||||
|
@ -313,19 +312,18 @@ typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add hour, minutes, seconds, and include the sign */
|
/* add hour, minutes, seconds together and include the sign */
|
||||||
seconds += 60 * minutes + 3600 * hours;
|
seconds += 60 * (PY_LONG_LONG)minutes + 3600 * (PY_LONG_LONG)hours;
|
||||||
|
|
||||||
if (sign < 0) {
|
if (sign < 0) {
|
||||||
seconds = -seconds;
|
seconds = -seconds;
|
||||||
micros = -micros;
|
micros = -micros;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the days - these items already included their own sign */
|
/* add the days, months years together - they already include a sign */
|
||||||
seconds += (3600 * 24) * (days + 30 * months + 365 * years);
|
days += 30 * (PY_LONG_LONG)months + 365 * (PY_LONG_LONG)years;
|
||||||
|
|
||||||
return PyObject_CallFunction((PyObject*)PyDateTimeAPI->DeltaType, "lll",
|
return PyObject_CallFunction((PyObject*)PyDateTimeAPI->DeltaType, "LLl",
|
||||||
0L, seconds, micros);
|
days, seconds, micros);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* psycopg defaults to using python datetime types */
|
/* psycopg defaults to using python datetime types */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user