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

Commite6ea61b

Browse files
committed
Merge branch 'REL9_6_STABLE' into PGPRO9_6
2 parentsf23efc3 +b971a98 commite6ea61b

File tree

26 files changed

+739
-664
lines changed

26 files changed

+739
-664
lines changed

‎doc/src/sgml/ref/create_database.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
258258
The <literal>CONNECTION LIMIT</> option is only enforced approximately;
259259
if two new sessions start at about the same time when just one
260260
connection <quote>slot</> remains for the database, it is possible that
261-
both will fail. Also, the limit is not enforced against superusers.
261+
both will fail. Also, the limit is not enforced against superusers or
262+
background worker processes.
262263
</para>
263264
</refsect1>
264265

‎doc/src/sgml/ref/create_role.sgml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ CREATE ROLE <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replac
198198
<listitem>
199199
<para>
200200
If role can log in, this specifies how many concurrent connections
201-
the role can make. -1 (the default) means no limit.
201+
the role can make. -1 (the default) means no limit. Note that only
202+
normal connections are counted towards this limit. Neither prepared
203+
transactions nor background worker connections are counted towards
204+
this limit.
202205
</para>
203206
</listitem>
204207
</varlistentry>

‎src/backend/access/transam/twophase.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ MarkAsPreparing(TransactionId xid, const char *gid,
420420
proc->backendId=InvalidBackendId;
421421
proc->databaseId=databaseid;
422422
proc->roleId=owner;
423+
proc->isBackgroundWorker= false;
423424
proc->lwWaiting= false;
424425
proc->lwWaitMode=0;
425426
proc->waitLock=NULL;

‎src/backend/optimizer/plan/createplan.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5634,6 +5634,16 @@ materialize_finished_plan(Plan *subplan)
56345634

56355635
matplan= (Plan*)make_material(subplan);
56365636

5637+
/*
5638+
* XXX horrid kluge: if there are any initPlans attached to the subplan,
5639+
* move them up to the Material node, which is now effectively the top
5640+
* plan node in its query level. This prevents failure in
5641+
* SS_finalize_plan(), which see for comments. We don't bother adjusting
5642+
* the subplan's cost estimate for this.
5643+
*/
5644+
matplan->initPlan=subplan->initPlan;
5645+
subplan->initPlan=NIL;
5646+
56375647
/* Set cost data */
56385648
cost_material(&matpath,
56395649
subplan->startup_cost,

‎src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
305305
if (cursorOptions&CURSOR_OPT_SCROLL)
306306
{
307307
if (!ExecSupportsBackwardScan(top_plan))
308-
{
309-
Plan*sub_plan=top_plan;
310-
311-
top_plan=materialize_finished_plan(sub_plan);
312-
313-
/*
314-
* XXX horrid kluge: if there are any initPlans attached to the
315-
* formerly-top plan node, move them up to the Material node. This
316-
* prevents failure in SS_finalize_plan, which see for comments.
317-
* We don't bother adjusting the sub_plan's cost estimate for
318-
* this.
319-
*/
320-
top_plan->initPlan=sub_plan->initPlan;
321-
sub_plan->initPlan=NIL;
322-
}
308+
top_plan=materialize_finished_plan(top_plan);
323309
}
324310

325311
/*

‎src/backend/storage/ipc/procarray.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,38 @@ CountDBBackends(Oid databaseid)
27512751
returncount;
27522752
}
27532753

2754+
/*
2755+
* CountDBConnections --- counts database backends ignoring any background
2756+
*worker processes
2757+
*/
2758+
int
2759+
CountDBConnections(Oiddatabaseid)
2760+
{
2761+
ProcArrayStruct*arrayP=procArray;
2762+
intcount=0;
2763+
intindex;
2764+
2765+
LWLockAcquire(ProcArrayLock,LW_SHARED);
2766+
2767+
for (index=0;index<arrayP->numProcs;index++)
2768+
{
2769+
intpgprocno=arrayP->pgprocnos[index];
2770+
volatilePGPROC*proc=&allProcs[pgprocno];
2771+
2772+
if (proc->pid==0)
2773+
continue;/* do not count prepared xacts */
2774+
if (proc->isBackgroundWorker)
2775+
continue;/* do not count background workers */
2776+
if (!OidIsValid(databaseid)||
2777+
proc->databaseId==databaseid)
2778+
count++;
2779+
}
2780+
2781+
LWLockRelease(ProcArrayLock);
2782+
2783+
returncount;
2784+
}
2785+
27542786
/*
27552787
* CancelDBBackends --- cancel backends that are using specified database
27562788
*/
@@ -2810,6 +2842,8 @@ CountUserBackends(Oid roleid)
28102842

28112843
if (proc->pid==0)
28122844
continue;/* do not count prepared xacts */
2845+
if (proc->isBackgroundWorker)
2846+
continue;/* do not count background workers */
28132847
if (proc->roleId==roleid)
28142848
count++;
28152849
}

‎src/backend/storage/lmgr/proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ InitProcess(void)
372372
MyProc->backendId=InvalidBackendId;
373373
MyProc->databaseId=InvalidOid;
374374
MyProc->roleId=InvalidOid;
375+
MyProc->isBackgroundWorker=IsBackgroundWorker;
375376
MyPgXact->delayChkpt= false;
376377
MyPgXact->vacuumFlags=0;
377378
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
@@ -544,6 +545,7 @@ InitAuxiliaryProcess(void)
544545
MyProc->backendId=InvalidBackendId;
545546
MyProc->databaseId=InvalidOid;
546547
MyProc->roleId=InvalidOid;
548+
MyProc->isBackgroundWorker=IsBackgroundWorker;
547549
MyPgXact->delayChkpt= false;
548550
MyPgXact->vacuumFlags=0;
549551
MyProc->lwWaiting= false;

‎src/backend/utils/init/postinit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ CheckMyDatabase(const char *name, bool am_superuser)
351351
*/
352352
if (dbform->datconnlimit >=0&&
353353
!am_superuser&&
354-
CountDBBackends(MyDatabaseId)>dbform->datconnlimit)
354+
CountDBConnections(MyDatabaseId)>dbform->datconnlimit)
355355
ereport(FATAL,
356356
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
357357
errmsg("too many connections for database \"%s\"",

‎src/backend/utils/mb/Unicode/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ GENERICMAPS = $(ISO8859MAPS) $(WINMAPS) \
4242
johab_to_utf8.map utf8_to_johab.map\
4343
uhc_to_utf8.map utf8_to_uhc.map\
4444
gbk_to_utf8.map utf8_to_gbk.map\
45-
koi8r_to_utf8.map utf8_to_koi8r.map
45+
koi8r_to_utf8.map utf8_to_koi8r.map\
46+
koi8u_to_utf8.map utf8_to_koi8u.map
4647

4748
SPECIALMAPS = euc_cn_to_utf8.map utf8_to_euc_cn.map\
4849
euc_jp_to_utf8.map utf8_to_euc_jp.map\

‎src/bin/pg_dump/dumputils.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,12 @@ buildACLCommands(const char *name, const char *subname,
368368
*/
369369
bool
370370
buildDefaultACLCommands(constchar*type,constchar*nspname,
371-
constchar*acls,constchar*owner,
371+
constchar*acls,constchar*racls,
372+
constchar*initacls,constchar*initracls,
373+
constchar*owner,
372374
intremoteVersion,
373375
PQExpBuffersql)
374376
{
375-
boolresult;
376377
PQExpBufferprefix;
377378

378379
prefix=createPQExpBuffer();
@@ -388,14 +389,22 @@ buildDefaultACLCommands(const char *type, const char *nspname,
388389
if (nspname)
389390
appendPQExpBuffer(prefix,"IN SCHEMA %s ",fmtId(nspname));
390391

391-
result=buildACLCommands("",NULL,
392-
type,acls,"",owner,
393-
prefix->data,remoteVersion,
394-
sql);
392+
if (strlen(initacls)!=0||strlen(initracls)!=0)
393+
{
394+
appendPQExpBuffer(sql,"SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
395+
if (!buildACLCommands("",NULL,type,initacls,initracls,owner,
396+
prefix->data,remoteVersion,sql))
397+
return false;
398+
appendPQExpBuffer(sql,"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
399+
}
400+
401+
if (!buildACLCommands("",NULL,type,acls,racls,owner,
402+
prefix->data,remoteVersion,sql))
403+
return false;
395404

396405
destroyPQExpBuffer(prefix);
397406

398-
returnresult;
407+
returntrue;
399408
}
400409

401410
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp