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

Commitca2995b

Browse files
committed
Remove duplicate CIDR funcs by using coerce entries.
1 parent9ac0c1e commitca2995b

File tree

8 files changed

+50
-94
lines changed

8 files changed

+50
-94
lines changed

‎src/backend/parser/parse_coerce.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.8 1998/10/08 18:29:43 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.9 1998/10/22 13:50:54 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -328,6 +328,11 @@ TypeCategory(Oid inType)
328328
result=GEOMETRIC_TYPE;
329329
break;
330330

331+
case (INETOID):
332+
case (CIDROID):
333+
result=NETWORK_TYPE;
334+
break;
335+
331336
default:
332337
result=USER_TYPE;
333338
break;
@@ -379,6 +384,10 @@ PreferredType(CATEGORY category, Oid type)
379384
result=TIMESPANOID;
380385
break;
381386

387+
case (NETWORK_TYPE):
388+
result=INETOID;
389+
break;
390+
382391
case (GEOMETRIC_TYPE):
383392
case (USER_TYPE):
384393
result=type;

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

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*is for IP V4 CIDR notation, but prepared for V6: just
44
*add the necessary bits where the comments indicate.
55
*
6-
*$Id: inet.c,v 1.12 1998/10/22 13:16:23 momjian Exp $
6+
*$Id: inet.c,v 1.13 1998/10/22 13:50:56 momjian Exp $
77
*Jon Postel RIP 16 Oct 1998
88
*/
99

@@ -297,7 +297,7 @@ inet_cmp(inet *a1, inet *a2)
297297
}
298298

299299
text*
300-
inet_host(inet*ip)
300+
host(inet*ip)
301301
{
302302
text*ret;
303303
intlen;
@@ -331,34 +331,22 @@ inet_host(inet *ip)
331331
ret=palloc(len);
332332
if (ret==NULL)
333333
{
334-
elog(ERROR,"unable to allocate memory ininet_host()");
334+
elog(ERROR,"unable to allocate memory inhost()");
335335
return (NULL);
336336
}
337337
VARSIZE(ret)=len;
338338
strcpy(VARDATA(ret),tmp);
339339
return (ret);
340340
}
341341

342-
text*
343-
cidr_host(inet*ip)
344-
{
345-
returninet_host(ip);
346-
}
347-
348342
int4
349-
inet_netmasklen(inet*ip)
343+
masklen(inet*ip)
350344
{
351345
returnip_bits(ip);
352346
}
353347

354-
int4
355-
cidr_netmasklen(inet*ip)
356-
{
357-
returninet_netmasklen(ip);
358-
}
359-
360348
text*
361-
inet_broadcast(inet*ip)
349+
broadcast(inet*ip)
362350
{
363351
text*ret;
364352
intlen;
@@ -390,7 +378,7 @@ inet_broadcast(inet *ip)
390378
ret=palloc(len);
391379
if (ret==NULL)
392380
{
393-
elog(ERROR,"unable to allocate memory ininet_broadcast()");
381+
elog(ERROR,"unable to allocate memory inbroadcast()");
394382
return (NULL);
395383
}
396384
VARSIZE(ret)=len;
@@ -399,13 +387,7 @@ inet_broadcast(inet *ip)
399387
}
400388

401389
text*
402-
cidr_broadcast(inet*ip)
403-
{
404-
returninet_broadcast(ip);
405-
}
406-
407-
text*
408-
inet_netmask(inet*ip)
390+
netmask(inet*ip)
409391
{
410392
text*ret;
411393
intlen;
@@ -435,20 +417,14 @@ inet_netmask(inet *ip)
435417
ret=palloc(len);
436418
if (ret==NULL)
437419
{
438-
elog(ERROR,"unable to allocate memory ininet_netmask()");
420+
elog(ERROR,"unable to allocate memory innetmask()");
439421
return (NULL);
440422
}
441423
VARSIZE(ret)=len;
442424
strcpy(VARDATA(ret),tmp);
443425
return (ret);
444426
}
445427

446-
text*
447-
cidr_netmask(inet*ip)
448-
{
449-
returninet_netmask(ip);
450-
}
451-
452428
/*
453429
*Bitwise comparison for V4 addresses. Add V6 implementation!
454430
*/

‎src/include/catalog/pg_amop.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_amop.h,v 1.17 1998/10/2205:29:23 momjian Exp $
10+
* $Id: pg_amop.h,v 1.18 1998/10/2213:50:58 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -322,11 +322,11 @@ DATA(insert OID = 0 ( 403 935 1205 5 btreesel btreenpage ));
322322
*nbtree cidr
323323
*/
324324

325-
DATA(insertOID=0 (4036528221btreeselbtreenpage ));
326-
DATA(insertOID=0 (4036528232btreeselbtreenpage ));
327-
DATA(insertOID=0 (4036528203btreeselbtreenpage ));
328-
DATA(insertOID=0 (4036528254btreeselbtreenpage ));
329-
DATA(insertOID=0 (4036528245btreeselbtreenpage ));
325+
DATA(insertOID=0 (40365212031btreeselbtreenpage ));
326+
DATA(insertOID=0 (40365212042btreeselbtreenpage ));
327+
DATA(insertOID=0 (40365212013btreeselbtreenpage ));
328+
DATA(insertOID=0 (40365212064btreeselbtreenpage ));
329+
DATA(insertOID=0 (40365212055btreeselbtreenpage ));
330330

331331
/*
332332
*hash table _ops

‎src/include/catalog/pg_operator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_operator.h,v 1.41 1998/10/21 16:06:46 momjian Exp $
10+
* $Id: pg_operator.h,v 1.42 1998/10/22 13:51:00 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -667,7 +667,6 @@ DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 828 0 0 in
667667
DATA(insertOID=828 (">>"PGUID0btf6506501682682700inet_supintltselintltjoinsel ));
668668
DATA(insertOID=1004 (">>="PGUID0btf6506501682782600inet_supeqintltselintltjoinsel ));
669669

670-
671670
/*
672671
* function prototypes
673672
*/

‎src/include/catalog/pg_proc.h

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
1/*-------------------------------------------------------------------------
1+
/*-------------------------------------------------------------------------
22
*
33
* pg_proc.h--
44
* definition of the system "procedure" relation (pg_proc)
55
* along with the relation's initial contents.
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.79 1998/10/2205:29:24 momjian Exp $
9+
* $Id: pg_proc.h,v 1.80 1998/10/2213:51:02 momjian Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2104,44 +2104,14 @@ DESCR("is-supernet");
21042104
DATA(insertOID=930 (inet_supeqPGUID11ftf2f16"869 869"10000100foobar ));
21052105
DESCR("is-supernet-or-equal");
21062106

2107-
/* inet base versions */
2108-
DATA(insertOID=940 (inet_netmaskPGUID11ftf1f25"869"10000100foobar ));
2107+
/* inet/cidr versions */
2108+
DATA(insertOID=940 (netmaskPGUID11ftf1f25"869"10000100foobar ));
21092109
DESCR("netmask of address");
2110-
DATA(insertOID=941 (inet_netmasklenPGUID11ftf1f23"869"10000100foobar ));
2110+
DATA(insertOID=941 (masklenPGUID11ftf1f23"869"10000100foobar ));
21112111
DESCR("netmask length");
2112-
DATA(insertOID=945 (inet_broadcastPGUID11ftf1f25"869"10000100foobar ));
2112+
DATA(insertOID=945 (broadcastPGUID11ftf1f25"869"10000100foobar ));
21132113
DESCR("broadcast address");
2114-
DATA(insertOID=682 (inet_hostPGUID11ftf1f25"869"10000100foobar ));
2115-
DESCR("host address");
2116-
2117-
/* cidr base versions */
2118-
DATA(insertOID=1619 (cidr_netmaskPGUID11ftf1f25"650"10000100foobar ));
2119-
DESCR("netmask of address");
2120-
DATA(insertOID=1620 (cidr_netmasklenPGUID11ftf1f23"650"10000100foobar ));
2121-
DESCR("netmask length");
2122-
DATA(insertOID=1621 (cidr_broadcastPGUID11ftf1f25"650"10000100foobar ));
2123-
DESCR("broadcast address");
2124-
DATA(insertOID=1622 (cidr_hostPGUID11ftf1f25"650"10000100foobar ));
2125-
DESCR("host address");
2126-
2127-
/* inet versions */
2128-
DATA(insertOID=946 (netmaskPGUID14ftf1f25"869"10000100"select inet_netmask($1)"- ));
2129-
DESCR("netmask of address");
2130-
DATA(insertOID=947 (netmasklenPGUID14ftf1f23"869"10000100"select inet_netmasklen($1)"- ));
2131-
DESCR("netmask length");
2132-
DATA(insertOID=948 (broadcastPGUID14ftf1f25"869"10000100"select inet_broadcast($1)"- ));
2133-
DESCR("broadcast address");
2134-
DATA(insertOID=949 (hostPGUID14ftf1f25"869"10000100"select inet_host($1)"- ));
2135-
DESCR("host address");
2136-
2137-
/* cidr versions */
2138-
DATA(insertOID=696 (netmaskPGUID14ftf1f25"650"10000100"select cidr_netmask($1)"- ));
2139-
DESCR("netmask of address");
2140-
DATA(insertOID=697 (netmasklenPGUID14ftf1f23"650"10000100"select cidr_netmasklen($1)"- ));
2141-
DESCR("netmask length");
2142-
DATA(insertOID=698 (broadcastPGUID14ftf1f25"650"10000100"select cidr_broadcast($1)"- ));
2143-
DESCR("broadcast address");
2144-
DATA(insertOID=699 (hostPGUID14ftf1f25"650"10000100"select cidr_host($1)"- ));
2114+
DATA(insertOID=682 (hostPGUID11ftf1f25"869"10000100foobar ));
21452115
DESCR("host address");
21462116

21472117

‎src/include/catalog/pg_type.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_type.h,v 1.51 1998/10/2200:35:26 momjian Exp $
10+
* $Id: pg_type.h,v 1.52 1998/10/2213:51:03 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -302,8 +302,10 @@ DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 00 macaddr_in macaddr
302302
DESCR("MAC address");
303303
DATA(insertOID=869 (inetPGUID-1-1fbt \05400inet_ininet_outinet_ininet_outi_null_ ));
304304
DESCR("Host address");
305+
#defineINETOID 869
305306
DATA(insertOID=650 (cidrPGUID-1-1fbt \05400cidr_incidr_outcidr_incidr_outi_null_ ));
306307
DESCR("Network address");
308+
#defineCIDROID 650
307309

308310
/* OIDS 900 - 999 */
309311

‎src/include/parser/parse_coerce.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: parse_coerce.h,v 1.6 1998/10/08 18:30:36 momjian Exp $
9+
* $Id: parse_coerce.h,v 1.7 1998/10/22 13:51:05 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,6 +23,7 @@ typedef enum CATEGORY
2323
DATETIME_TYPE,
2424
TIMESPAN_TYPE,
2525
GEOMETRIC_TYPE,
26+
NETWORK_TYPE,
2627
USER_TYPE,
2728
MIXED_TYPE
2829
}CATEGORY;
@@ -56,7 +57,9 @@ typedef enum CATEGORY
5657
|| ((t) == BOXOID) \
5758
|| ((t) == PATHOID) \
5859
|| ((t) == POLYGONOID) \
59-
|| ((t) == CIRCLEOID))
60+
|| ((t) == CIRCLEOID) \
61+
|| ((t) == INETOID) \
62+
|| ((t) == CIDROID) )
6063

6164

6265
/* IS_BINARY_COMPATIBLE()
@@ -83,7 +86,9 @@ typedef enum CATEGORY
8386
|| ((a) == INT4OID && (b) == ABSTIMEOID) \
8487
|| ((a) == INT4OID && (b) == TIMESTAMPOID) \
8588
|| ((a) == RELTIMEOID && (b) == INT4OID) \
86-
|| ((a) == INT4OID && (b) == RELTIMEOID))
89+
|| ((a) == INT4OID && (b) == RELTIMEOID) \
90+
|| ((a) == INETOID && (b) == CIDROID) \
91+
|| ((a) == CIDROID && (b) == INETOID))
8792

8893
/* IS_HIGHER_TYPE()
8994
* These types are the most general in each of the type categories.
@@ -93,7 +98,8 @@ typedef enum CATEGORY
9398
|| ((t) == FLOAT8OID) \
9499
|| ((t) == TIMESPANOID) \
95100
|| ((t) == DATETIMEOID) \
96-
|| ((t) == POLYGONOID))
101+
|| ((t) == POLYGONOID) \
102+
|| ((t) == INETOID) )
97103

98104
/* IS_HIGHEST_TYPE()
99105
* These types are the most general in each of the type categories.

‎src/include/utils/builtins.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: builtins.h,v 1.66 1998/10/22 13:16:27 momjian Exp $
9+
* $Id: builtins.h,v 1.67 1998/10/22 13:51:07 momjian Exp $
1010
*
1111
* NOTES
1212
* This should normally only be included by fmgr.h.
@@ -533,16 +533,10 @@ boolinet_sup(inet * a1, inet * a2);
533533
boolinet_supeq(inet*a1,inet*a2);
534534
int4inet_cmp(inet*a1,inet*a2);
535535

536-
text*inet_netmask(inet*addr);
537-
int4inet_netmasklen(inet*addr);
538-
text*inet_broadcast(inet*addr);
539-
text*inet_host(inet*addr);
540-
541-
text*cidr_netmask(inet*addr);
542-
int4cidr_netmasklen(inet*addr);
543-
text*cidr_broadcast(inet*addr);
544-
text*cidr_host(inet*addr);
545-
536+
text*netmask(inet*addr);
537+
int4masklen(inet*addr);
538+
text*broadcast(inet*addr);
539+
text*host(inet*addr);
546540

547541
/* mac.c */
548542
macaddr*macaddr_in(char*str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp