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

Commitf3f3aae

Browse files
committed
Improve conversions from uint64 to Perl types.
Perl's integers are pointer-sized, so can hold more than INT_MAX on LP64platforms, and come in both signed (IV) and unsigned (UV). Floatingpoint values (NV) may also be larger than double.Since Perl 5.19.4 array indices are SSize_t instead of I32, so allow upto SSize_t_max on those versions. The limit is not imposed just byav_extend's argument type, but all the array handling code, so removethe speculative comment.Dagfinn Ilmari Mannsåker
1 parent6be84ee commitf3f3aae

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

‎src/pl/plperl/plperl.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,22 +3104,18 @@ plperl_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 processed,
31043104
hv_store_string(result,"status",
31053105
cstr2sv(SPI_result_code_string(status)));
31063106
hv_store_string(result,"processed",
3107-
(processed> (uint64)INT_MAX) ?
3108-
newSVnv((double)processed) :
3109-
newSViv((int)processed));
3107+
(processed> (uint64)UV_MAX) ?
3108+
newSVnv((NV)processed) :
3109+
newSVuv((UV)processed));
31103110

31113111
if (status>0&&tuptable)
31123112
{
31133113
AV*rows;
31143114
SV*row;
31153115
uint64i;
31163116

3117-
/*
3118-
* av_extend's 2nd argument is declared I32. It's possible we could
3119-
* nonetheless push more than INT_MAX elements into a Perl array, but
3120-
* let's just fail instead of trying.
3121-
*/
3122-
if (processed> (uint64)INT_MAX)
3117+
/* Prevent overflow in call to av_extend() */
3118+
if (processed> (uint64)AV_SIZE_MAX)
31233119
ereport(ERROR,
31243120
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
31253121
errmsg("query result has too many rows to fit in a Perl array")));

‎src/pl/plperl/plperl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
#defineGvCV_set(gv,cv)(GvCV(gv) = cv)
8989
#endif
9090

91+
/* Perl 5.19.4 changed array indices from I32 to SSize_t */
92+
#ifPERL_BCDVERSION >=0x5019004
93+
#defineAV_SIZE_MAX SSize_t_MAX
94+
#else
95+
#defineAV_SIZE_MAX I32_MAX
96+
#endif
97+
9198
/* declare routines from plperl.c for access by .xs files */
9299
HV*plperl_spi_exec(char*,int);
93100
voidplperl_return_next(SV*);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp