home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / access / nobtree / nobtcompare.c next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.5 KB  |  119 lines

  1. /*
  2.  *  btcompare.c -- Comparison functions for btree access method.
  3.  *
  4.  *    These functions are stored in pg_amproc.  For each operator class
  5.  *    defined on btrees, they compute
  6.  *
  7.  *        compare(a, b):
  8.  *            < 0 if a < b,
  9.  *            = 0 if a == b,
  10.  *            > 0 if a > b.
  11.  */
  12.  
  13. #include "tmp/c.h"
  14.  
  15. #ifdef NOBTREE
  16. #include "tmp/postgres.h"
  17. RcsId("$Header: /private/postgres/src/access/nobtree/RCS/nobtcompare.c,v 1.6 1991/06/26 19:12:14 mao Exp $");
  18.  
  19. int32
  20. nobtint2cmp(a, b)
  21.     int16 a, b;
  22. {
  23.     return ((int32) (a - b));
  24. }
  25.  
  26. int32
  27. nobtint4cmp(a, b)
  28.     int32 a, b;
  29. {
  30.     return (a - b);
  31. }
  32.  
  33. int32
  34. nobtint24cmp(a, b)
  35.     int16 a;
  36.     int32 b;
  37. {
  38.     return (((int32) a) - b);
  39. }
  40.  
  41. int32
  42. nobtint42cmp(a, b)
  43.     int32 a;
  44.     int16 b;
  45. {
  46.     return (a - ((int32) b));
  47. }
  48.  
  49. int32
  50. nobtfloat4cmp(a, b)
  51.     float32 a, b;
  52. {
  53.     if (a > b)
  54.     return (1);
  55.     else if (a == b)
  56.     return (0);
  57.     else
  58.     return (-1);
  59. }
  60.  
  61. int32
  62. nobtfloat8cmp(a, b)
  63.     float64 a, b;
  64. {
  65.     if (a > b)
  66.     return (1);
  67.     else if (a == b)
  68.     return (0);
  69.     else
  70.     return (-1);
  71. }
  72.  
  73. int32
  74. nobtoidcmp(a, b)
  75.     ObjectId a, b;
  76. {
  77.     if (a > b)
  78.     return (1);
  79.     else if (a == b)
  80.     return (0);
  81.     else
  82.     return (-1);
  83. }
  84.  
  85. int32
  86. nobtabstimecmp(a, b)
  87.     AbsoluteTime a, b;
  88. {
  89.     if (AbsoluteTimeIsBefore(a, b))
  90.     return (1);
  91.     else if (AbsoluteTimeIsBefore(b, a))
  92.     return (-1);
  93.     else
  94.     return (0);
  95. }
  96.  
  97. int32
  98. nobtcharcmp(a, b)
  99.     char a, b;
  100. {
  101.     return ((int32) (a - b));
  102. }
  103.  
  104. int32
  105. nobtchar16cmp(a, b)
  106.     Name a;
  107.     Name b;
  108. {
  109.     return (strncmp(a, b, 16));
  110. }
  111.  
  112. int32
  113. nobttextcmp(a, b)
  114.     char *a, *b;
  115. {
  116.     return (strcmp(a, b));
  117. }
  118. #endif /* NOBTREE */
  119.