diff options
author | Thomas G. Lockhart <lockhart@fourpalms.org> | 2000-04-08 02:13:11 +0000 |
---|---|---|
committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 2000-04-08 02:13:11 +0000 |
commit | 0337938fbfee45a2406b12e34cc594e72af58c3c (patch) | |
tree | 742177886e2c4a8c12b91b526405d21cb4eec4fa /src/include | |
parent | 6a2d926933d6d67147f4b624b1401eebdd1c33ce (diff) |
Add zpbit and varbit data types from Adrian Joubert
<a.joubert@albourne.com>.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/pg_operator.h | 31 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.h | 81 | ||||
-rw-r--r-- | src/include/catalog/pg_type.h | 22 | ||||
-rw-r--r-- | src/include/utils/builtins.h | 3 | ||||
-rw-r--r-- | src/include/utils/varbit.h | 87 |
5 files changed, 213 insertions, 11 deletions
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 0189184cfc2..2150bac98de 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.73 2000/04/07 13:39:49 thomas Exp $ + * $Id: pg_operator.h,v 1.74 2000/04/08 02:13:00 thomas Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -716,6 +716,35 @@ DATA(insert OID = 1660 ( "<=" PGUID 0 b t f 1625 1625 16 1662 1661 0 0 DATA(insert OID = 1661 ( ">" PGUID 0 b t f 1625 1625 16 1659 1660 0 0 lztext_gt intgtsel intgtjoinsel )); DATA(insert OID = 1662 ( ">=" PGUID 0 b t f 1625 1625 16 1660 1659 0 0 lztext_ge intgtsel intgtjoinsel )); +DATA(insert OID = 1784 ( "=" PGUID 0 b t f 1560 1560 16 1784 1785 1786 1786 biteq eqsel eqjoinsel )); +DATA(insert OID = 1785 ( "<>" PGUID 0 b t f 1560 1560 16 1785 1784 0 0 bitne neqsel neqjoinsel )); +DATA(insert OID = 1786 ( "<" PGUID 0 b t f 1560 1560 16 1787 1789 0 0 bitlt intltsel intltjoinsel )); +DATA(insert OID = 1787 ( ">" PGUID 0 b t f 1560 1560 16 1786 1788 0 0 bitgt intgtsel intgtjoinsel )); +DATA(insert OID = 1788 ( "<=" PGUID 0 b t f 1560 1560 16 1789 1787 0 0 bitle intltsel intltjoinsel )); +DATA(insert OID = 1789 ( ">=" PGUID 0 b t f 1560 1560 16 1788 1786 0 0 bitge intgtsel intgtjoinsel )); +DATA(insert OID = 1790 ( "<=>" PGUID 0 b t f 1560 1560 23 0 0 0 0 bitcmp - - )); +DATA(insert OID = 1791 ( "&" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitand - - )); +DATA(insert OID = 1792 ( "|" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitor - - )); +DATA(insert OID = 1793 ( "^" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitxor - - )); +DATA(insert OID = 1794 ( "~" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitnot - - )); +DATA(insert OID = 1795 ( "<<" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitshiftleft - - )); +DATA(insert OID = 1796 ( ">>" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitshiftright - - )); +DATA(insert OID = 1797 ( "||" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitcat - - )); + +DATA(insert OID = 1804 ( "=" PGUID 0 b t f 1562 1562 16 1804 1805 1806 1806 varbiteq eqsel eqjoinsel )); +DATA(insert OID = 1805 ( "<>" PGUID 0 b t f 1562 1562 16 1805 1804 0 0 varbitne neqsel neqjoinsel )); +DATA(insert OID = 1806 ( "<" PGUID 0 b t f 1562 1562 16 1807 1809 0 0 varbitlt intltsel intltjoinsel )); +DATA(insert OID = 1807 ( ">" PGUID 0 b t f 1562 1562 16 1806 1808 0 0 varbitgt intgtsel intgtjoinsel )); +DATA(insert OID = 1808 ( "<=" PGUID 0 b t f 1562 1562 16 1809 1807 0 0 varbitle intltsel intltjoinsel )); +DATA(insert OID = 1809 ( ">=" PGUID 0 b t f 1562 1562 16 1808 1806 0 0 varbitge intgtsel intgtjoinsel )); +DATA(insert OID = 1810 ( "<=>" PGUID 0 b t f 1562 1562 23 0 0 0 0 varbitcmp - - )); +DATA(insert OID = 1811 ( "&" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitand - - )); +DATA(insert OID = 1812 ( "|" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitor - - )); +DATA(insert OID = 1813 ( "^" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitxor - - )); +DATA(insert OID = 1814 ( "~" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitnot - - )); +DATA(insert OID = 1815 ( "<<" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitshiftleft - - )); +DATA(insert OID = 1816 ( ">>" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitshiftright - - )); +DATA(insert OID = 1817 ( "||" PGUID 0 b t f 1562 1562 1562 0 0 0 0 varbitcat - - )); /* * function prototypes diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 24fa3f7325f..c38c1c84a43 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.130 2000/04/07 13:39:49 thomas Exp $ + * $Id: pg_proc.h,v 1.131 2000/04/08 02:13:00 thomas Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -1979,8 +1979,11 @@ DATA(insert OID = 1545 ( npoints PGUID 11 f t t 1 f 23 "602" 100 0 0 100 pat DESCR("# points in path"); DATA(insert OID = 1556 ( npoints PGUID 11 f t t 1 f 23 "604" 100 0 0 100 poly_npoints - )); DESCR("number of points in polygon"); -DATA(insert OID = 1573 ( int8 PGUID 14 f t t 1 f 20 "20" 100 0 0 100 "select $1" - )); -DESCR("convert int8 to int8 (no-op)"); + +DATA(insert OID = 1564 ( zpbit_in PGUID 11 f t t 1 f 1560 "0" 100 0 0 100 zpbit_in - )); +DESCR("(internal)"); +DATA(insert OID = 1565 ( zpbit_out PGUID 11 f t t 1 f 23 "0" 100 0 0 100 zpbit_out - )); +DESCR("(internal)"); DATA(insert OID = 1569 ( like PGUID 11 f t t 2 f 16 "25 25" 100 0 1 0 textlike - )); DESCR("matches LIKE expression"); @@ -1990,6 +1993,9 @@ DATA(insert OID = 1571 ( like PGUID 11 f t t 2 f 16 "19 25" 100 0 0 100 nam DESCR("matches LIKE expression"); DATA(insert OID = 1572 ( notlike PGUID 11 f t t 2 f 16 "19 25" 100 0 0 100 namenlike - )); DESCR("does not match LIKE expression"); +DATA(insert OID = 1573 ( int8 PGUID 14 f t t 1 f 20 "20" 100 0 0 100 "select $1" - )); +DESCR("convert int8 to int8 (no-op)"); + /* SEQUENCEs nextval & currval functions */ DATA(insert OID = 1574 ( nextval PGUID 11 f t f 1 f 23 "25" 100 0 0 100 nextval - )); @@ -1999,6 +2005,26 @@ DESCR("sequence current value"); DATA(insert OID = 1576 ( setval PGUID 11 f t f 2 f 23 "25 23" 100 0 0 100 setval - )); DESCR("sequence set value"); +DATA(insert OID = 1579 ( varbit_in PGUID 11 f t t 1 f 1562 "0" 100 0 0 100 varbit_in - )); +DESCR("(internal)"); +DATA(insert OID = 1580 ( varbit_out PGUID 11 f t t 1 f 23 "0" 100 0 0 100 varbit_out - )); +DESCR("(internal)"); + +DATA(insert OID = 1581 ( biteq PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 biteq - )); +DESCR("equal"); +DATA(insert OID = 1582 ( bitne PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 bitne - )); +DESCR("not equal"); +DATA(insert OID = 1592 ( bitge PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 bitge - )); +DESCR("greater than or equal"); +DATA(insert OID = 1593 ( bitgt PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 bitgt - )); +DESCR("greater than"); +DATA(insert OID = 1594 ( bitle PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 bitle - )); +DESCR("less than or equal"); +DATA(insert OID = 1595 ( bitlt PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0 bitlt - )); +DESCR("less than"); +DATA(insert OID = 1596 ( bitcmp PGUID 11 f t t 2 f 23 "1560 1560" 100 0 1 0 bitcmp - )); +DESCR("compare"); + DATA(insert OID = 1598 ( random PGUID 11 f t f 0 f 701 "0" 100 0 0 100 drandom - )); DESCR("radians to degrees"); DATA(insert OID = 1599 ( setseed PGUID 11 f t t 1 f 23 "701" 100 0 0 100 setseed - )); @@ -2159,6 +2185,55 @@ DESCR("referential integrity ON DELETE NO ACTION"); DATA(insert OID = 1655 ( RI_FKey_noaction_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_noaction_upd - )); DESCR("referential integrity ON UPDATE NO ACTION"); +DATA(insert OID = 1666 ( varbiteq PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbiteq - )); +DESCR("equal"); +DATA(insert OID = 1667 ( varbitne PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbitne - )); +DESCR("not equal"); +DATA(insert OID = 1668 ( varbitge PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbitge - )); +DESCR("greater than or equal"); +DATA(insert OID = 1669 ( varbitgt PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbitgt - )); +DESCR("greater than"); +DATA(insert OID = 1670 ( varbitle PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbitle - )); +DESCR("less than or equal"); +DATA(insert OID = 1671 ( varbitlt PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0 varbitlt - )); +DESCR("less than"); +DATA(insert OID = 1672 ( varbitcmp PGUID 11 f t t 2 f 23 "1562 1562" 100 0 1 0 varbitcmp - )); +DESCR("compare"); + +DATA(insert OID = 1673 ( bitand PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitand - )); +DESCR("bitwise and"); +DATA(insert OID = 1674 ( bitor PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitor - )); +DESCR("bitwise or"); +DATA(insert OID = 1675 ( bitxor PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitxor - )); +DESCR("bitwise exclusive or"); +DATA(insert OID = 1676 ( bitnot PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitnot - )); +DESCR("bitwise negation"); +DATA(insert OID = 1677 ( bitshiftright PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitshiftright - )); +DESCR("bitwise right shift"); +DATA(insert OID = 1678 ( bitshiftleft PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitshiftleft - )); +DESCR("bitwise left shift"); +DATA(insert OID = 1679 ( bitcat PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitcat - )); +DESCR("bitwise concatenation"); +DATA(insert OID = 1680 ( bitsubstr PGUID 11 f t t 2 f 1560 "1560 1560" 100 0 1 0 bitsubstr - )); +DESCR("bitwise field"); + +DATA(insert OID = 1681 ( varbitand PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitand - )); +DESCR("bitwise and"); +DATA(insert OID = 1682 ( varbitor PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitor - )); +DESCR("bitwise or"); +DATA(insert OID = 1683 ( varbitxor PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitxor - )); +DESCR("bitwise exclusive or"); +DATA(insert OID = 1684 ( varbitnot PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitnot - )); +DESCR("bitwise negation"); +DATA(insert OID = 1685 ( varbitshiftright PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitshiftright - )); +DESCR("bitwise right shift"); +DATA(insert OID = 1686 ( varbitshiftleft PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitshiftleft - )); +DESCR("bitwise left shift"); +DATA(insert OID = 1687 ( varbitcat PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitcat - )); +DESCR("bitwise concatenation"); +DATA(insert OID = 1688 ( varbitsubstr PGUID 11 f t t 2 f 1562 "1562 1562" 100 0 1 0 varbitsubstr - )); +DESCR("bitwise field"); + /* for mac type support */ DATA(insert OID = 436 ( macaddr_in PGUID 11 f t t 1 f 829 "0" 100 0 0 100 macaddr_in - )); DESCR("(internal)"); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index d49ee9047ed..61bbfeab858 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.86 2000/03/18 20:50:10 momjian Exp $ + * $Id: pg_type.h,v 1.87 2000/04/08 02:13:01 thomas Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -382,16 +382,26 @@ DESCR("hh:mm:ss, ANSI SQL time"); #define TIMETZOID 1266 DATA(insert OID = 1270 ( _timetz PGUID -1 -1 f b t \054 0 1266 array_in array_out array_in array_out d _null_ )); +/* OIDS 1500 - 1599 */ +DATA(insert OID = 1560 ( bit PGUID -1 -1 f b t \054 0 0 zpbit_in zpbit_out zpbit_in zpbit_out i _null_ )); +DESCR("fixed-length bit string"); +#define ZPBITOID 1560 +DATA(insert OID = 1561 ( _bit PGUID -1 -1 f b t \054 0 1560 array_in array_out array_in array_out i _null_ )); +DATA(insert OID = 1562 ( varbit PGUID -1 -1 f b t \054 0 0 varbit_in varbit_out varbit_in varbit_out i _null_ )); +DESCR("fixed-length bit string"); +#define VARBITOID 1562 +DATA(insert OID = 1563 ( _varbit PGUID -1 -1 f b t \054 0 1562 array_in array_out array_in array_out i _null_ )); + +/* OIDS 1600 - 1699 */ +DATA(insert OID = 1625 ( lztext PGUID -1 -1 f b t \054 0 0 lztextin lztextout lztextin lztextout i _null_ )); +DESCR("variable-length string, stored compressed"); +#define LZTEXTOID 1625 + /* OIDS 1700 - 1799 */ DATA(insert OID = 1700 ( numeric PGUID -1 -1 f b t \054 0 0 numeric_in numeric_out numeric_in numeric_out i _null_ )); DESCR("numeric(precision, decimal), arbitrary precision number"); #define NUMERICOID 1700 -/* OIDS 1625 - 1639 */ -DATA(insert OID = 1625 ( lztext PGUID -1 -1 f b t \054 0 0 lztextin lztextout lztextin lztextout i _null_ )); -DESCR("variable-length string, stored compressed"); -#define LZTEXTOID 1625 - #define VARLENA_FIXED_SIZE(attr) ((attr)->atttypid == BPCHAROID && (attr)->atttypmod > 0) /* diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 4e6cbaaace0..270187e9173 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.108 2000/04/07 13:40:12 thomas Exp $ + * $Id: builtins.h,v 1.109 2000/04/08 02:13:10 thomas Exp $ * * NOTES * This should normally only be included by fmgr.h. @@ -36,6 +36,7 @@ #include "utils/nabstime.h" #include "utils/date.h" #include "utils/lztext.h" +#include "utils/varbit.h" /* * Defined in adt/ diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h new file mode 100644 index 00000000000..9ee0724b01d --- /dev/null +++ b/src/include/utils/varbit.h @@ -0,0 +1,87 @@ +#ifndef VARBIT_H +#define VARBIT_H + +#include <math.h> + +#include "postgres.h" +#ifdef HAVE_LIMITS_H +#include <limits.h> +#ifndef MAXINT +#define MAXINT INT_MAX +#endif +#else +#ifdef HAVE_VALUES_H +#include <values.h> +#endif +#endif +#include "utils/builtins.h" + + +#define HEXDIG(z) (z)<10 ? ((z)+'0') : ((z)-10+'A') + +/* Modeled on struct varlena from postgres.h, bu data type is bits8 */ +struct varbita +{ + int32 vl_len; + bits8 vl_dat[1]; +}; + +#define BITSPERBYTE 8 +#define VARBITHDRSZ sizeof(int32) +/* Number of bits in this bit string */ +#define VARBITLEN(PTR) (((struct varbita *)VARDATA(PTR))->vl_len) +/* Pointer tp the first byte containing bit string data */ +#define VARBITS(PTR) (((struct varbita *)VARDATA(PTR))->vl_dat) +/* Number of bytes in the data section of a bit string */ +#define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ) +/* Padding of the bit string at the end */ +#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITSPERBYTE - VARBITLEN(PTR)) +/* Number of bytes needed to store a bit string of a given length */ +#define VARBITDATALEN(BITLEN) ((BITLEN)/BITSPERBYTE + \ + ((BITLEN)%BITSPERBYTE > 0 ? 1 : 0) + \ + VARHDRSZ + VARBITHDRSZ) +/* pointer beyond the end of the bit string (like end() in STL containers) */ +#define VARBITEND(PTR) ((bits8 *) (PTR + VARSIZE(PTR))) +/* Mask that will cover exactly one byte, i.e. BITSPERBYTE bits */ +#define BITMASK 0xFF +#define BITHIGH 0x80 + + +bits8 * zpbit_in(char *s, int dummy, int32 atttypmod); +char * zpbit_out(bits8 *s); +char * zpbits_out(bits8 *s); +bits8 * varbit_in(char *s, int dummy, int32 atttypmod); +char * varbit_out (bits8 *s); +bool biteq (bits8 *arg1, bits8 *arg2); +bool bitne (bits8 *arg1, bits8 *arg2); +bool bitge (bits8 *arg1, bits8 *arg2); +bool bitgt (bits8 *arg1, bits8 *arg2); +bool bitle (bits8 *arg1, bits8 *arg2); +bool bitlt (bits8 *arg1, bits8 *arg2); +int bitcmp (bits8 *arg1, bits8 *arg2); +bits8 * bitand (bits8 * arg1, bits8 * arg2); +bits8 * bitor (bits8 * arg1, bits8 * arg2); +bits8 * bitxor (bits8 * arg1, bits8 * arg2); +bits8 * bitnot (bits8 * arg); +bits8 * bitshiftright (bits8 * arg, int shft); +bits8 * bitshiftleft (bits8 * arg, int shft); +bits8 * bitcat (bits8 *arg1, bits8 *arg2); +bits8 * bitsubstr (bits8 *arg, int32 s, int32 l); + +bool varbiteq (bits8 *arg1, bits8 *arg2); +bool varbitne (bits8 *arg1, bits8 *arg2); +bool varbitge (bits8 *arg1, bits8 *arg2); +bool varbitgt (bits8 *arg1, bits8 *arg2); +bool varbitle (bits8 *arg1, bits8 *arg2); +bool varbitlt (bits8 *arg1, bits8 *arg2); +int varbitcmp (bits8 *arg1, bits8 *arg2); +bits8 * varbitand (bits8 * arg1, bits8 * arg2); +bits8 * varbitor (bits8 * arg1, bits8 * arg2); +bits8 * varbitxor (bits8 * arg1, bits8 * arg2); +bits8 * varbitnot (bits8 * arg); +bits8 * varbitshiftright (bits8 * arg, int shft); +bits8 * varbitshiftleft (bits8 * arg, int shft); +bits8 * varbitcat (bits8 *arg1, bits8 *arg2); +bits8 * varbitsubstr (bits8 *arg, int32 s, int32 l); + +#endif |