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

Commitdd1c781

Browse files
committed
Make get_stack_depth_rlimit() handle RLIM_INFINITY more sanely.
Rather than considering this result as meaning "unknown", report LONG_MAX.This won't change what superusers can set max_stack_depth to, but it willcause InitializeGUCOptions() to set the built-in default to 2MB not 100kB.The latter seems like a fairly unreasonable interpretation of "infinity".Per my investigation of odd buildfarm results as well as an old complaintfrom Heikki.Since this should persuade all the buildfarm animals to use a reasonablestack depth setting during "make check", revert previous patch that dumbeddown a recursive regression test to only 5 levels.
1 parent6736916 commitdd1c781

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
#include"postgres.h"
2121

22+
#include<fcntl.h>
23+
#include<limits.h>
24+
#include<signal.h>
2225
#include<time.h>
2326
#include<unistd.h>
24-
#include<signal.h>
25-
#include<fcntl.h>
2627
#include<sys/socket.h>
2728
#ifdefHAVE_SYS_SELECT_H
2829
#include<sys/select.h>
@@ -4107,7 +4108,7 @@ PostgresMain(int argc, char *argv[], const char *username)
41074108
/*
41084109
* Obtain platform stack depth limit (in bytes)
41094110
*
4110-
* Return -1 ifunlimited or not known
4111+
* Return -1 ifunknown
41114112
*/
41124113
long
41134114
get_stack_depth_rlimit(void)
@@ -4123,7 +4124,10 @@ get_stack_depth_rlimit(void)
41234124
if (getrlimit(RLIMIT_STACK,&rlim)<0)
41244125
val=-1;
41254126
elseif (rlim.rlim_cur==RLIM_INFINITY)
4126-
val=-1;
4127+
val=LONG_MAX;
4128+
/* rlim_cur is probably of an unsigned type, so check for overflow */
4129+
elseif (rlim.rlim_cur >=LONG_MAX)
4130+
val=LONG_MAX;
41274131
else
41284132
val=rlim.rlim_cur;
41294133
}

‎src/backend/utils/misc/guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,14 +3485,14 @@ InitializeGUCOptions(void)
34853485
stack_rlimit=get_stack_depth_rlimit();
34863486
if (stack_rlimit>0)
34873487
{
3488-
intnew_limit= (stack_rlimit-STACK_DEPTH_SLOP) /1024L;
3488+
longnew_limit= (stack_rlimit-STACK_DEPTH_SLOP) /1024L;
34893489

34903490
if (new_limit>100)
34913491
{
34923492
charlimbuf[16];
34933493

34943494
new_limit=Min(new_limit,2048);
3495-
sprintf(limbuf,"%d",new_limit);
3495+
sprintf(limbuf,"%ld",new_limit);
34963496
SetConfigOption("max_stack_depth",limbuf,
34973497
PGC_POSTMASTER,PGC_S_ENV_VAR);
34983498
}

‎src/test/regress/expected/plpgsql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4006,7 +4006,7 @@ $$ language plpgsql;
40064006
-- "limit" is to prevent this from being inlined
40074007
create function sql_recurse(float8) returns float8 as
40084008
$$ select recurse($1) limit 1; $$ language sql;
4009-
select recurse(5);
4009+
select recurse(10);
40104010
recurse
40114011
---------
40124012
0

‎src/test/regress/sql/plpgsql.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,7 +3211,7 @@ $$ language plpgsql;
32113211
createfunctionsql_recurse(float8) returns float8as
32123212
$$select recurse($1)limit1; $$ language sql;
32133213

3214-
select recurse(5);
3214+
select recurse(10);
32153215

32163216
createfunctionerror1(text) returnstext language sqlas
32173217
$$SELECT relname::textFROM pg_class cWHEREc.oid= $1::regclass $$;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp