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

Commit6a7bb0a

Browse files
committed
Prevent tv_sec from becoming negative in connection timeout code.
1 parentc231133 commit6a7bb0a

File tree

6 files changed

+68
-27
lines changed

6 files changed

+68
-27
lines changed

‎doc/src/FAQ/FAQ.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ <H2 align="center">Operational Questions</H2>
143143
from a function?<BR>
144144
<Ahref="#4.26">4.26</A>) Why can't I reliably create/drop
145145
temporary tables in PL/PgSQL functions?<BR>
146+
<Ahref="#4.27">4.27</A>) What replication options are available?<BR>
146147

147148

148149
<H2align="center">Extending PostgreSQL</H2>
@@ -1346,12 +1347,14 @@ <H4><A name="4.23">4.23</A>) How do I perform an outer join?</H4>
13461347
<H4><Aname="4.24">4.24</A>) How do I perform queries using
13471348
multiple databases?</H4>
13481349

1349-
<P>There is no way to queryany databaseexcept the current one.
1350+
<P>There is no way to querya databaseother than the current one.
13501351
Because PostgreSQL loads database-specific system catalogs, it is
13511352
uncertain how a cross-database query should even behave.</P>
13521353

1353-
<P>Of course, a client can make simultaneous connections to
1354-
different databases and merge the information that way.</P>
1354+
<P><I>/contrib/dblink</I> allows cross-database queries using
1355+
function calls. Of course, a client can make simultaneous
1356+
connections to different databases and merge the results on the
1357+
client side.</P>
13551358

13561359
<H4><Aname="4.25">4.25</A>) How do I return multiple rows or
13571360
columns from a function?</H4>
@@ -1364,13 +1367,19 @@ <H4><A name="4.25">4.25</A>) How do I return multiple rows or
13641367

13651368
<H4><Aname="4.26">4.26</A>) Why can't I reliably create/drop
13661369
temporary tables in PL/PgSQL functions?</H4>
1367-
PL/PgSQL caches function contents, and an unfortunate side effect
1370+
<P>PL/PgSQL caches function contents, and an unfortunate side effect
13681371
is that if a PL/PgSQL function accesses a temporary table, and that
13691372
table is later dropped and recreated, and the function called
13701373
again, the function will fail because the cached function contents
13711374
still point to the old temporary table. The solution is to use
13721375
<SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This
1373-
will cause the query to be reparsed every time.
1376+
will cause the query to be reparsed every time.</P>
1377+
1378+
<H4><Aname="4.27">4.27</A>) What replication options are available?
1379+
</H4>
1380+
<P>There are several master/slave replication solutions available.
1381+
These allow only one server to make database changes and the slave
1382+
merely allow database reading.
13741383

13751384
<HR>
13761385

‎src/backend/nodes/nodes.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.15 2002/06/20 20:29:29 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.16 2002/10/11 04:12:14 momjian Exp $
1313
*
1414
* HISTORY
1515
* Andrew YuOct 20, 1994file creation
@@ -28,15 +28,5 @@
2828
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
2929
*
3030
*/
31-
Node*
32-
newNode(Sizesize,NodeTagtag)
33-
{
34-
Node*newNode;
31+
Node*newNodeMacroHolder;
3532

36-
Assert(size >=sizeof(Node));/* need the tag, at least */
37-
38-
newNode= (Node*)palloc(size);
39-
MemSet((char*)newNode,0,size);
40-
newNode->type=tag;
41-
returnnewNode;
42-
}

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.32 2002/08/12 00:36:12 tgl Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.33 2002/10/11 04:12:14 momjian Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -452,6 +452,29 @@ MemoryContextAlloc(MemoryContext context, Size size)
452452
return (*context->methods->alloc) (context,size);
453453
}
454454

455+
/*
456+
* MemoryContextAllocZero
457+
*Like MemoryContextAlloc, but clears allocated memory
458+
*
459+
*We could just call MemoryContextAlloc then clear the memory, but this
460+
*function is called too many times, so we have a separate version.
461+
*/
462+
void*
463+
MemoryContextAllocZero(MemoryContextcontext,Sizesize)
464+
{
465+
void*ret;
466+
467+
AssertArg(MemoryContextIsValid(context));
468+
469+
if (!AllocSizeIsValid(size))
470+
elog(ERROR,"MemoryContextAllocZero: invalid request size %lu",
471+
(unsigned long)size);
472+
473+
ret= (*context->methods->alloc) (context,size);
474+
MemSet(ret,0,size);
475+
returnret;
476+
}
477+
455478
/*
456479
* pfree
457480
*Release an allocated chunk.

‎src/include/nodes/nodes.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: nodes.h,v 1.118 2002/08/31 22:10:47 tgl Exp $
10+
* $Id: nodes.h,v 1.119 2002/10/11 04:12:14 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -261,6 +261,24 @@ typedef struct Node
261261

262262
#definenodeTag(nodeptr)(((Node*)(nodeptr))->type)
263263

264+
/*
265+
*There is no way to dereference the palloc'ed pointer to assign the
266+
*tag, and return the pointer itself, so we need a holder variable.
267+
*Fortunately, this function isn't recursive so we just define
268+
*a global variable for this purpose.
269+
*/
270+
externNode*newNodeMacroHolder;
271+
272+
#definenewNode(size,tag) \
273+
( \
274+
AssertMacro((size) >= sizeof(Node)),/* need the tag, at least */ \
275+
\
276+
newNodeMacroHolder = (Node *) palloc0(size), \
277+
newNodeMacroHolder->type = (tag), \
278+
newNodeMacroHolder \
279+
)
280+
281+
264282
#definemakeNode(_type_)((_type_ *) newNode(sizeof(_type_),T_##_type_))
265283
#defineNodeSetTag(nodeptr,t)(((Node*)(nodeptr))->type = (t))
266284

@@ -282,11 +300,6 @@ typedef struct Node
282300
* ----------------------------------------------------------------
283301
*/
284302

285-
/*
286-
* nodes/nodes.c
287-
*/
288-
externNode*newNode(Sizesize,NodeTagtag);
289-
290303
/*
291304
* nodes/{outfuncs.c,print.c}
292305
*/

‎src/include/utils/palloc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
24-
* $Id: palloc.h,v 1.19 2002/06/20 20:29:53 momjian Exp $
24+
* $Id: palloc.h,v 1.20 2002/10/11 04:12:14 momjian Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -46,9 +46,12 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext;
4646
* Fundamental memory-allocation operations (more are in utils/memutils.h)
4747
*/
4848
externvoid*MemoryContextAlloc(MemoryContextcontext,Sizesize);
49+
externvoid*MemoryContextAllocZero(MemoryContextcontext,Sizesize);
4950

5051
#definepalloc(sz)MemoryContextAlloc(CurrentMemoryContext, (sz))
5152

53+
#definepalloc0(sz)MemoryContextAllocZero(CurrentMemoryContext, (sz))
54+
5255
externvoidpfree(void*pointer);
5356

5457
externvoid*repalloc(void*pointer,Sizesize);

‎src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.206 2002/10/03 17:09:42 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.207 2002/10/11 04:12:14 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1131,7 +1131,10 @@ connectDBComplete(PGconn *conn)
11311131
return0;
11321132
}
11331133

1134-
remains.tv_sec=finish_time-current_time;
1134+
if (finish_time>current_time)
1135+
remains.tv_sec=finish_time-current_time;
1136+
else
1137+
remains.tv_sec=0;
11351138
remains.tv_usec=0;
11361139
}
11371140
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp