From 1f747c67222842b93ad833675aca20001a6dd9f8 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 29 Nov 1999 22:34:36 +0000 Subject: Attached are the C-routines that implement a BIT and BIT VARYING type. Adriaan Joubert --- contrib/bit/vartest.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 contrib/bit/vartest.c (limited to 'contrib/bit/vartest.c') diff --git a/contrib/bit/vartest.c b/contrib/bit/vartest.c new file mode 100644 index 00000000000..732141e8df4 --- /dev/null +++ b/contrib/bit/vartest.c @@ -0,0 +1,172 @@ +#include "postgres.h" +#include "varbit.h" +#include + +const int numb = 8; +/* +const char *b[] = { "B0010", "B11011011", "B0001", "X3F12", "X27", "B", + "X11", "B100111"}; +int atttypmod[] = {-1, -1, -1,-1,-1,-1,-1,-1 }; +*/ +const char *b[] = { "B0010", "B11011011", "B10001", "X3D12", "X27", "B", + "X11", "B100111"}; +int atttypmod[] = { 7, 9, 6, 18, 11, 6, -1, -1 }; + + +void print_details (unsigned char *s) +{ + int i; + printf ("Length in bytes : %d\n",VARSIZE(s)); + printf ("Length of bitstring: %d\n",VARBITLEN(s)); + for (i=8; i>4,s[i]&0xF); + printf("\n"); +} + +void +main () +{ + int i, j; + char *s[numb]; + + for (i=0; i %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]), + bitcmp(s[i],s[j])); + + printf ("\nCONCATENATION:\n"); + for (i=0; i %s\n",zpbitsout(s[3]),1,8, + zpbitsout(bitsubstr(s[3],1,8))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8, + zpbitsout(bitsubstr(s[3],9,8))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9, + zpbitsout(bitsubstr(s[3],1,9))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5, + zpbitsout(bitsubstr(s[3],3,5))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9, + zpbitsout(bitsubstr(s[3],3,9))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,17, + zpbitsout(bitsubstr(s[3],3,17))); + printf ("\nLOGICAL AND:\n"); + for (i=0; i %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]), + bitcmp(s[i],s[j])); + + printf ("\nCONCATENATION:\n"); + for (i=0; i %s\n",zpbitsout(s[3]),1,8, + zpbitsout(bitsubstr(s[3],1,8))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8, + zpbitsout(bitsubstr(s[3],9,8))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9, + zpbitsout(bitsubstr(s[3],1,9))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5, + zpbitsout(bitsubstr(s[3],3,5))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9, + zpbitsout(bitsubstr(s[3],3,9))); + printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,17, + zpbitsout(bitsubstr(s[3],3,17))); + printf ("\nLOGICAL AND:\n"); + for (i=0; i