Commit ca2995be authored by Bruce Momjian's avatar Bruce Momjian

Remove duplicate CIDR funcs by using coerce entries.

parent 9ac0c1e3
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.8 1998/10/08 18:29:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.9 1998/10/22 13:50:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -328,6 +328,11 @@ TypeCategory(Oid inType) ...@@ -328,6 +328,11 @@ TypeCategory(Oid inType)
result = GEOMETRIC_TYPE; result = GEOMETRIC_TYPE;
break; break;
case (INETOID):
case (CIDROID):
result = NETWORK_TYPE;
break;
default: default:
result = USER_TYPE; result = USER_TYPE;
break; break;
...@@ -379,6 +384,10 @@ PreferredType(CATEGORY category, Oid type) ...@@ -379,6 +384,10 @@ PreferredType(CATEGORY category, Oid type)
result = TIMESPANOID; result = TIMESPANOID;
break; break;
case (NETWORK_TYPE):
result = INETOID;
break;
case (GEOMETRIC_TYPE): case (GEOMETRIC_TYPE):
case (USER_TYPE): case (USER_TYPE):
result = type; result = type;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just * is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate. * add the necessary bits where the comments indicate.
* *
* $Id: inet.c,v 1.12 1998/10/22 13:16:23 momjian Exp $ * $Id: inet.c,v 1.13 1998/10/22 13:50:56 momjian Exp $
* Jon Postel RIP 16 Oct 1998 * Jon Postel RIP 16 Oct 1998
*/ */
...@@ -297,7 +297,7 @@ inet_cmp(inet *a1, inet *a2) ...@@ -297,7 +297,7 @@ inet_cmp(inet *a1, inet *a2)
} }
text * text *
inet_host(inet *ip) host(inet *ip)
{ {
text *ret; text *ret;
int len; int len;
...@@ -331,7 +331,7 @@ inet_host(inet *ip) ...@@ -331,7 +331,7 @@ inet_host(inet *ip)
ret = palloc(len); ret = palloc(len);
if (ret == NULL) if (ret == NULL)
{ {
elog(ERROR, "unable to allocate memory in inet_host()"); elog(ERROR, "unable to allocate memory in host()");
return (NULL); return (NULL);
} }
VARSIZE(ret) = len; VARSIZE(ret) = len;
...@@ -339,26 +339,14 @@ inet_host(inet *ip) ...@@ -339,26 +339,14 @@ inet_host(inet *ip)
return (ret); return (ret);
} }
text *
cidr_host(inet *ip)
{
return inet_host(ip);
}
int4 int4
inet_netmasklen(inet *ip) masklen(inet *ip)
{ {
return ip_bits(ip); return ip_bits(ip);
} }
int4
cidr_netmasklen(inet *ip)
{
return inet_netmasklen(ip);
}
text * text *
inet_broadcast(inet *ip) broadcast(inet *ip)
{ {
text *ret; text *ret;
int len; int len;
...@@ -390,7 +378,7 @@ inet_broadcast(inet *ip) ...@@ -390,7 +378,7 @@ inet_broadcast(inet *ip)
ret = palloc(len); ret = palloc(len);
if (ret == NULL) if (ret == NULL)
{ {
elog(ERROR, "unable to allocate memory in inet_broadcast()"); elog(ERROR, "unable to allocate memory in broadcast()");
return (NULL); return (NULL);
} }
VARSIZE(ret) = len; VARSIZE(ret) = len;
...@@ -399,13 +387,7 @@ inet_broadcast(inet *ip) ...@@ -399,13 +387,7 @@ inet_broadcast(inet *ip)
} }
text * text *
cidr_broadcast(inet *ip) netmask(inet *ip)
{
return inet_broadcast(ip);
}
text *
inet_netmask(inet *ip)
{ {
text *ret; text *ret;
int len; int len;
...@@ -435,7 +417,7 @@ inet_netmask(inet *ip) ...@@ -435,7 +417,7 @@ inet_netmask(inet *ip)
ret = palloc(len); ret = palloc(len);
if (ret == NULL) if (ret == NULL)
{ {
elog(ERROR, "unable to allocate memory in inet_netmask()"); elog(ERROR, "unable to allocate memory in netmask()");
return (NULL); return (NULL);
} }
VARSIZE(ret) = len; VARSIZE(ret) = len;
...@@ -443,12 +425,6 @@ inet_netmask(inet *ip) ...@@ -443,12 +425,6 @@ inet_netmask(inet *ip)
return (ret); return (ret);
} }
text *
cidr_netmask(inet *ip)
{
return inet_netmask(ip);
}
/* /*
* Bitwise comparison for V4 addresses. Add V6 implementation! * Bitwise comparison for V4 addresses. Add V6 implementation!
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_amop.h,v 1.17 1998/10/22 05:29:23 momjian Exp $ * $Id: pg_amop.h,v 1.18 1998/10/22 13:50:58 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -322,11 +322,11 @@ DATA(insert OID = 0 ( 403 935 1205 5 btreesel btreenpage )); ...@@ -322,11 +322,11 @@ DATA(insert OID = 0 ( 403 935 1205 5 btreesel btreenpage ));
* nbtree cidr * nbtree cidr
*/ */
DATA(insert OID = 0 ( 403 652 822 1 btreesel btreenpage )); DATA(insert OID = 0 ( 403 652 1203 1 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 652 823 2 btreesel btreenpage )); DATA(insert OID = 0 ( 403 652 1204 2 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 652 820 3 btreesel btreenpage )); DATA(insert OID = 0 ( 403 652 1201 3 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 652 825 4 btreesel btreenpage )); DATA(insert OID = 0 ( 403 652 1206 4 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 652 824 5 btreesel btreenpage )); DATA(insert OID = 0 ( 403 652 1205 5 btreesel btreenpage ));
/* /*
* hash table _ops * hash table _ops
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_operator.h,v 1.41 1998/10/21 16:06:46 momjian Exp $ * $Id: pg_operator.h,v 1.42 1998/10/22 13:51:00 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * 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 ...@@ -667,7 +667,6 @@ DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 828 0 0 in
DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 827 0 0 inet_sup intltsel intltjoinsel )); DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 827 0 0 inet_sup intltsel intltjoinsel ));
DATA(insert OID = 1004 ( ">>=" PGUID 0 b t f 650 650 16 827 826 0 0 inet_supeq intltsel intltjoinsel )); DATA(insert OID = 1004 ( ">>=" PGUID 0 b t f 650 650 16 827 826 0 0 inet_supeq intltsel intltjoinsel ));
/* /*
* function prototypes * function prototypes
*/ */
......
1/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* pg_proc.h-- * pg_proc.h--
* definition of the system "procedure" relation (pg_proc) * definition of the system "procedure" relation (pg_proc)
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_proc.h,v 1.79 1998/10/22 05:29:24 momjian Exp $ * $Id: pg_proc.h,v 1.80 1998/10/22 13:51:02 momjian Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
...@@ -2104,44 +2104,14 @@ DESCR("is-supernet"); ...@@ -2104,44 +2104,14 @@ DESCR("is-supernet");
DATA(insert OID = 930 ( inet_supeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar )); DATA(insert OID = 930 ( inet_supeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("is-supernet-or-equal"); DESCR("is-supernet-or-equal");
/* inet base versions */ /* inet/cidr versions */
DATA(insert OID = 940 ( inet_netmask PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar )); DATA(insert OID = 940 ( netmask PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar ));
DESCR("netmask of address"); DESCR("netmask of address");
DATA(insert OID = 941 ( inet_netmasklen PGUID 11 f t f 1 f 23 "869" 100 0 0 100 foo bar )); DATA(insert OID = 941 ( masklen PGUID 11 f t f 1 f 23 "869" 100 0 0 100 foo bar ));
DESCR("netmask length"); DESCR("netmask length");
DATA(insert OID = 945 ( inet_broadcast PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar )); DATA(insert OID = 945 ( broadcast PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar ));
DESCR("broadcast address"); DESCR("broadcast address");
DATA(insert OID = 682 ( inet_host PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar )); DATA(insert OID = 682 ( host PGUID 11 f t f 1 f 25 "869" 100 0 0 100 foo bar ));
DESCR("host address");
/* cidr base versions */
DATA(insert OID = 1619 ( cidr_netmask PGUID 11 f t f 1 f 25 "650" 100 0 0 100 foo bar ));
DESCR("netmask of address");
DATA(insert OID = 1620 ( cidr_netmasklen PGUID 11 f t f 1 f 23 "650" 100 0 0 100 foo bar ));
DESCR("netmask length");
DATA(insert OID = 1621 ( cidr_broadcast PGUID 11 f t f 1 f 25 "650" 100 0 0 100 foo bar ));
DESCR("broadcast address");
DATA(insert OID = 1622 ( cidr_host PGUID 11 f t f 1 f 25 "650" 100 0 0 100 foo bar ));
DESCR("host address");
/* inet versions */
DATA(insert OID = 946 ( netmask PGUID 14 f t f 1 f 25 "869" 100 0 0 100 "select inet_netmask($1)" - ));
DESCR("netmask of address");
DATA(insert OID = 947 ( netmasklen PGUID 14 f t f 1 f 23 "869" 100 0 0 100 "select inet_netmasklen($1)" - ));
DESCR("netmask length");
DATA(insert OID = 948 ( broadcast PGUID 14 f t f 1 f 25 "869" 100 0 0 100 "select inet_broadcast($1)" - ));
DESCR("broadcast address");
DATA(insert OID = 949 ( host PGUID 14 f t f 1 f 25 "869" 100 0 0 100 "select inet_host($1)" - ));
DESCR("host address");
/* cidr versions */
DATA(insert OID = 696 ( netmask PGUID 14 f t f 1 f 25 "650" 100 0 0 100 "select cidr_netmask($1)" - ));
DESCR("netmask of address");
DATA(insert OID = 697 ( netmasklen PGUID 14 f t f 1 f 23 "650" 100 0 0 100 "select cidr_netmasklen($1)" - ));
DESCR("netmask length");
DATA(insert OID = 698 ( broadcast PGUID 14 f t f 1 f 25 "650" 100 0 0 100 "select cidr_broadcast($1)" - ));
DESCR("broadcast address");
DATA(insert OID = 699 ( host PGUID 14 f t f 1 f 25 "650" 100 0 0 100 "select cidr_host($1)" - ));
DESCR("host address"); DESCR("host address");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_type.h,v 1.51 1998/10/22 00:35:26 momjian Exp $ * $Id: pg_type.h,v 1.52 1998/10/22 13:51:03 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * 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 0 0 macaddr_in macaddr ...@@ -302,8 +302,10 @@ DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 0 0 macaddr_in macaddr
DESCR("MAC address"); DESCR("MAC address");
DATA(insert OID = 869 ( inet PGUID -1 -1 f b t \054 0 0 inet_in inet_out inet_in inet_out i _null_ )); DATA(insert OID = 869 ( inet PGUID -1 -1 f b t \054 0 0 inet_in inet_out inet_in inet_out i _null_ ));
DESCR("Host address"); DESCR("Host address");
#define INETOID 869
DATA(insert OID = 650 ( cidr PGUID -1 -1 f b t \054 0 0 cidr_in cidr_out cidr_in cidr_out i _null_ )); DATA(insert OID = 650 ( cidr PGUID -1 -1 f b t \054 0 0 cidr_in cidr_out cidr_in cidr_out i _null_ ));
DESCR("Network address"); DESCR("Network address");
#define CIDROID 650
/* OIDS 900 - 999 */ /* OIDS 900 - 999 */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_coerce.h,v 1.6 1998/10/08 18:30:36 momjian Exp $ * $Id: parse_coerce.h,v 1.7 1998/10/22 13:51:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -23,6 +23,7 @@ typedef enum CATEGORY ...@@ -23,6 +23,7 @@ typedef enum CATEGORY
DATETIME_TYPE, DATETIME_TYPE,
TIMESPAN_TYPE, TIMESPAN_TYPE,
GEOMETRIC_TYPE, GEOMETRIC_TYPE,
NETWORK_TYPE,
USER_TYPE, USER_TYPE,
MIXED_TYPE MIXED_TYPE
} CATEGORY; } CATEGORY;
...@@ -56,7 +57,9 @@ typedef enum CATEGORY ...@@ -56,7 +57,9 @@ typedef enum CATEGORY
|| ((t) == BOXOID) \ || ((t) == BOXOID) \
|| ((t) == PATHOID) \ || ((t) == PATHOID) \
|| ((t) == POLYGONOID) \ || ((t) == POLYGONOID) \
|| ((t) == CIRCLEOID)) || ((t) == CIRCLEOID) \
|| ((t) == INETOID) \
|| ((t) == CIDROID) )
/* IS_BINARY_COMPATIBLE() /* IS_BINARY_COMPATIBLE()
...@@ -83,7 +86,9 @@ typedef enum CATEGORY ...@@ -83,7 +86,9 @@ typedef enum CATEGORY
|| ((a) == INT4OID && (b) == ABSTIMEOID) \ || ((a) == INT4OID && (b) == ABSTIMEOID) \
|| ((a) == INT4OID && (b) == TIMESTAMPOID) \ || ((a) == INT4OID && (b) == TIMESTAMPOID) \
|| ((a) == RELTIMEOID && (b) == INT4OID) \ || ((a) == RELTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == RELTIMEOID)) || ((a) == INT4OID && (b) == RELTIMEOID) \
|| ((a) == INETOID && (b) == CIDROID) \
|| ((a) == CIDROID && (b) == INETOID))
/* IS_HIGHER_TYPE() /* IS_HIGHER_TYPE()
* These types are the most general in each of the type categories. * These types are the most general in each of the type categories.
...@@ -93,7 +98,8 @@ typedef enum CATEGORY ...@@ -93,7 +98,8 @@ typedef enum CATEGORY
|| ((t) == FLOAT8OID) \ || ((t) == FLOAT8OID) \
|| ((t) == TIMESPANOID) \ || ((t) == TIMESPANOID) \
|| ((t) == DATETIMEOID) \ || ((t) == DATETIMEOID) \
|| ((t) == POLYGONOID)) || ((t) == POLYGONOID) \
|| ((t) == INETOID) )
/* IS_HIGHEST_TYPE() /* IS_HIGHEST_TYPE()
* These types are the most general in each of the type categories. * These types are the most general in each of the type categories.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: builtins.h,v 1.66 1998/10/22 13:16:27 momjian Exp $ * $Id: builtins.h,v 1.67 1998/10/22 13:51:07 momjian Exp $
* *
* NOTES * NOTES
* This should normally only be included by fmgr.h. * This should normally only be included by fmgr.h.
...@@ -533,16 +533,10 @@ bool inet_sup(inet * a1, inet * a2); ...@@ -533,16 +533,10 @@ bool inet_sup(inet * a1, inet * a2);
bool inet_supeq(inet * a1, inet * a2); bool inet_supeq(inet * a1, inet * a2);
int4 inet_cmp(inet * a1, inet * a2); int4 inet_cmp(inet * a1, inet * a2);
text *inet_netmask(inet * addr); text *netmask(inet * addr);
int4 inet_netmasklen(inet * addr); int4 masklen(inet * addr);
text *inet_broadcast(inet * addr); text *broadcast(inet * addr);
text *inet_host(inet * addr); text *host(inet * addr);
text *cidr_netmask(inet * addr);
int4 cidr_netmasklen(inet * addr);
text *cidr_broadcast(inet * addr);
text *cidr_host(inet * addr);
/* mac.c */ /* mac.c */
macaddr *macaddr_in(char *str); macaddr *macaddr_in(char *str);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment