Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit918e02a

Browse files
committed
Improve type conversion of SPI_processed in Python
The previous code converted SPI_processed to a Python float if it didn'tfit into a Python int. But Python longs have unlimited precision, souse that instead in all cases.As ineee50a8, we use the PythonLongLong API unconditionally for simplicity.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
1 parent96102a3 commit918e02a

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

‎src/pl/plpython/plpy_cursorobject.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,7 @@ PLy_cursor_fetch(PyObject *self, PyObject *args)
444444
ret->status=PyInt_FromLong(SPI_OK_FETCH);
445445

446446
Py_DECREF(ret->nrows);
447-
ret->nrows= (SPI_processed> (uint64)LONG_MAX) ?
448-
PyFloat_FromDouble((double)SPI_processed) :
449-
PyInt_FromLong((long)SPI_processed);
447+
ret->nrows=PyLong_FromUnsignedLongLong(SPI_processed);
450448

451449
if (SPI_processed!=0)
452450
{

‎src/pl/plpython/plpy_spi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,15 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 rows, int status)
371371
if (status>0&&tuptable==NULL)
372372
{
373373
Py_DECREF(result->nrows);
374-
result->nrows= (rows> (uint64)LONG_MAX) ?
375-
PyFloat_FromDouble((double)rows) :
376-
PyInt_FromLong((long)rows);
374+
result->nrows=PyLong_FromUnsignedLongLong(rows);
377375
}
378376
elseif (status>0&&tuptable!=NULL)
379377
{
380378
PLyDatumToObininfo;
381379
MemoryContextcxt;
382380

383381
Py_DECREF(result->nrows);
384-
result->nrows= (rows> (uint64)LONG_MAX) ?
385-
PyFloat_FromDouble((double)rows) :
386-
PyInt_FromLong((long)rows);
382+
result->nrows=PyLong_FromUnsignedLongLong(rows);
387383

388384
cxt=AllocSetContextCreate(CurrentMemoryContext,
389385
"PL/Python temp context",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp