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

Commitfc8e6c7

Browse files
committed
Oops, commited a test version of this file by accident. Revert.
1 parent393f313 commitfc8e6c7

File tree

2 files changed

+73
-59
lines changed

2 files changed

+73
-59
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.74 2000/02/21 18:47:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.75 2000/02/21 18:49:00 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -453,7 +453,6 @@ BufferAlloc(Relation reln,
453453
*/
454454
Assert(buf->refcount==0);
455455
buf->refcount=1;
456-
Assert(PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]==0);
457456
PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]=1;
458457

459458
if (buf->flags&BM_DIRTY)
@@ -543,7 +542,6 @@ BufferAlloc(Relation reln,
543542
inProgress= FALSE;
544543
buf->flags &= ~BM_IO_IN_PROGRESS;
545544
TerminateBufferIO(buf);
546-
Assert(PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]==1);
547545
PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]=0;
548546
buf->refcount--;
549547
buf= (BufferDesc*)NULL;
@@ -570,7 +568,6 @@ BufferAlloc(Relation reln,
570568
{
571569
TerminateBufferIO(buf);
572570
/* give up the buffer since we don't need it any more */
573-
Assert(PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]==1);
574571
PrivateRefCount[BufferDescriptorGetBuffer(buf)-1]=0;
575572
Assert(buf->refcount>0);
576573
buf->refcount--;
@@ -1472,16 +1469,8 @@ ReleaseRelationBuffers(Relation rel)
14721469
if (!(buf->flags&BM_FREE))
14731470
{
14741471
/* Assert checks that buffer will actually get freed! */
1475-
Assert(buf->refcount==1);
1476-
if (PrivateRefCount[i-1] <=0)
1477-
{
1478-
fprintf(stderr,"Nonpositive PrivateRefCount on buffer for %s\n",
1479-
RelationGetRelationName(rel));
1480-
fflush(stderr);
1481-
* ((char*)0)=0;
1482-
abort();
1483-
}
1484-
Assert(PrivateRefCount[i-1]==1);
1472+
Assert(PrivateRefCount[i-1]==1&&
1473+
buf->refcount==1);
14851474
/* ReleaseBuffer expects we do not hold the lock at entry */
14861475
SpinRelease(BufMgrLock);
14871476
holding= false;

‎src/backend/utils/adt/network.c

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@
33
*is for IP V4 CIDR notation, but prepared for V6: just
44
*add the necessary bits where the comments indicate.
55
*
6-
*$Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.17 2000/02/21 18:47:07 tgl Exp $
7-
*
6+
*$Id: network.c,v 1.18 2000/02/21 18:49:54 tgl Exp $
87
*Jon Postel RIP 16 Oct 1998
98
*/
109

11-
#include"postgres.h"
12-
1310
#include<sys/types.h>
1411
#include<sys/socket.h>
12+
1513
#include<errno.h>
14+
1615
#include<netinet/in.h>
1716
#include<arpa/inet.h>
1817

18+
#include"postgres.h"
1919
#include"utils/builtins.h"
2020

21-
22-
staticintv4bitncmp(unsigned longa1,unsigned longa2,intbits);
21+
staticintv4bitncmp(unsignedinta1,unsignedinta2,intbits);
2322

2423
/*
2524
*Access macros.Add IPV6 support.
@@ -40,7 +39,6 @@ static intv4bitncmp(unsigned long a1, unsigned long a2, int bits);
4039
#defineip_v4addr(inetptr) \
4140
(((inet_struct *)VARDATA(inetptr))->addr.ipv4_addr)
4241

43-
4442
/* Common input routine */
4543
staticinet*
4644
network_in(char*src,inttype)
@@ -129,85 +127,92 @@ cidr_out(inet *src)
129127
}
130128

131129
/*
132-
*Boolean tests for ordering operators --- must agree with sorting
133-
*operator network_cmp().
130+
*Boolean tests for magnitude. Add V4/V6 testing!
134131
*/
135132

136133
bool
137134
network_lt(inet*a1,inet*a2)
138135
{
139136
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
140137
return FALSE;
141-
return (bool) (network_cmp(a1,a2)<0);
138+
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
139+
{
140+
intorder=v4bitncmp(ip_v4addr(a1),ip_v4addr(a2),ip_bits(a2));
141+
142+
return ((order<0)|| ((order==0)&& (ip_bits(a1)<ip_bits(a2))));
143+
}
144+
else
145+
{
146+
/* Go for an IPV6 address here, before faulting out: */
147+
elog(ERROR,"cannot compare address families %d and %d",
148+
ip_family(a1),ip_family(a2));
149+
return FALSE;
150+
}
142151
}
143152

144153
bool
145154
network_le(inet*a1,inet*a2)
146155
{
147156
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
148157
return FALSE;
149-
return (bool) (network_cmp(a1,a2)<=0);
158+
return (network_lt(a1,a2)||network_eq(a1,a2));
150159
}
151160

152161
bool
153162
network_eq(inet*a1,inet*a2)
154163
{
155164
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
156165
return FALSE;
157-
return (bool) (network_cmp(a1,a2)==0);
166+
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
167+
{
168+
return ((ip_bits(a1)==ip_bits(a2))
169+
&& (v4bitncmp(ip_v4addr(a1),ip_v4addr(a2),ip_bits(a1))==0));
170+
}
171+
else
172+
{
173+
/* Go for an IPV6 address here, before faulting out: */
174+
elog(ERROR,"cannot compare address families %d and %d",
175+
ip_family(a1),ip_family(a2));
176+
return FALSE;
177+
}
158178
}
159179

160180
bool
161181
network_ge(inet*a1,inet*a2)
162182
{
163183
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
164184
return FALSE;
165-
return (bool) (network_cmp(a1,a2)>=0);
185+
return (network_gt(a1,a2)||network_eq(a1,a2));
166186
}
167187

168188
bool
169189
network_gt(inet*a1,inet*a2)
170190
{
171191
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
172192
return FALSE;
173-
return (bool) (network_cmp(a1,a2)>0);
174-
}
175-
176-
bool
177-
network_ne(inet*a1,inet*a2)
178-
{
179-
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
180-
return FALSE;
181-
return (bool) (network_cmp(a1,a2)!=0);
182-
}
183-
184-
/*
185-
*Comparison function for sorting. Add V4/V6 testing!
186-
*/
187-
188-
int4
189-
network_cmp(inet*a1,inet*a2)
190-
{
191193
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
192194
{
193-
intorder=v4bitncmp(ip_v4addr(a1),ip_v4addr(a2),
194-
(ip_bits(a1)<ip_bits(a2)) ?
195-
ip_bits(a1) :ip_bits(a2));
196-
197-
if (order)
198-
returnorder;
199-
/* They agree in the first N bits, so shorter one comes first */
200-
return (int)ip_bits(a1)- (int)ip_bits(a2);
195+
intorder=v4bitncmp(ip_v4addr(a1),ip_v4addr(a2),ip_bits(a2));
196+
197+
return ((order>0)|| ((order==0)&& (ip_bits(a1)>ip_bits(a2))));
201198
}
202199
else
203200
{
204201
/* Go for an IPV6 address here, before faulting out: */
205202
elog(ERROR,"cannot compare address families %d and %d",
206203
ip_family(a1),ip_family(a2));
207-
return0;
204+
returnFALSE;
208205
}
209206
}
210207

208+
bool
209+
network_ne(inet*a1,inet*a2)
210+
{
211+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
212+
return FALSE;
213+
return (!network_eq(a1,a2));
214+
}
215+
211216
bool
212217
network_sub(inet*a1,inet*a2)
213218
{
@@ -288,6 +293,28 @@ network_supeq(inet *a1, inet *a2)
288293
}
289294
}
290295

296+
/*
297+
*Comparison function for sorting. Add V4/V6 testing!
298+
*/
299+
300+
int4
301+
network_cmp(inet*a1,inet*a2)
302+
{
303+
if (ntohl(ip_v4addr(a1))<ntohl(ip_v4addr(a2)))
304+
return (-1);
305+
306+
if (ntohl(ip_v4addr(a1))>ntohl(ip_v4addr(a2)))
307+
return (1);
308+
309+
if (ip_bits(a1)<ip_bits(a2))
310+
return (-1);
311+
312+
if (ip_bits(a1)>ip_bits(a2))
313+
return (1);
314+
315+
return0;
316+
}
317+
291318
text*
292319
network_host(inet*ip)
293320
{
@@ -449,7 +476,7 @@ network_netmask(inet *ip)
449476
*/
450477

451478
staticint
452-
v4bitncmp(unsignedlonga1,unsignedlonga2,intbits)
479+
v4bitncmp(unsignedinta1,unsignedinta2,intbits)
453480
{
454481
unsigned longmask=0;
455482
inti;
@@ -458,11 +485,9 @@ v4bitncmp(unsigned long a1, unsigned long a2, int bits)
458485
mask= (mask >>1) |0x80000000;
459486
a1=ntohl(a1);
460487
a2=ntohl(a2);
461-
a1 &=mask;
462-
a2 &=mask;
463-
if (a1<a2)
488+
if ((a1&mask)< (a2&mask))
464489
return (-1);
465-
elseif (a1>a2)
490+
elseif ((a1&mask)> (a2&mask))
466491
return (1);
467492
return (0);
468493
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp