Commit 0346ab71 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Lexicographically compare 'char' and 'text'.

parent dee872de
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.4 1997/05/17 06:20:34 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.5 1997/06/11 05:17:58 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -129,17 +129,10 @@ char *char16out(char *s) ...@@ -129,17 +129,10 @@ char *char16out(char *s)
bool chareq(int8 arg1, int8 arg2) { return(arg1 == arg2); } bool chareq(int8 arg1, int8 arg2) { return(arg1 == arg2); }
bool charne(int8 arg1, int8 arg2) { return(arg1 != arg2); } bool charne(int8 arg1, int8 arg2) { return(arg1 != arg2); }
#ifdef UNSIGNED_CHAR_TEXT
bool charlt(int8 arg1, int8 arg2) { return((uint8)arg1 < (uint8)arg2); } bool charlt(int8 arg1, int8 arg2) { return((uint8)arg1 < (uint8)arg2); }
bool charle(int8 arg1, int8 arg2) { return((uint8)arg1 <= (uint8)arg2); } bool charle(int8 arg1, int8 arg2) { return((uint8)arg1 <= (uint8)arg2); }
bool chargt(int8 arg1, int8 arg2) { return((uint8)arg1 > (uint8)arg2); } bool chargt(int8 arg1, int8 arg2) { return((uint8)arg1 > (uint8)arg2); }
bool charge(int8 arg1, int8 arg2) { return((uint8)arg1 >= (uint8)arg2); } bool charge(int8 arg1, int8 arg2) { return((uint8)arg1 >= (uint8)arg2); }
#else
bool charlt(int8 arg1, int8 arg2) { return(arg1 < arg2); }
bool charle(int8 arg1, int8 arg2) { return(arg1 <= arg2); }
bool chargt(int8 arg1, int8 arg2) { return(arg1 > arg2); }
bool charge(int8 arg1, int8 arg2) { return(arg1 >= arg2); }
#endif
int8 charpl(int8 arg1, int8 arg2) { return(arg1 + arg2); } int8 charpl(int8 arg1, int8 arg2) { return(arg1 + arg2); }
int8 charmi(int8 arg1, int8 arg2) { return(arg1 - arg2); } int8 charmi(int8 arg1, int8 arg2) { return(arg1 - arg2); }
int8 charmul(int8 arg1, int8 arg2) { return(arg1 * arg2); } int8 charmul(int8 arg1, int8 arg2) { return(arg1 * arg2); }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.15 1997/04/25 18:40:39 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.16 1997/06/11 05:18:02 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -301,10 +301,7 @@ text_lt(struct varlena *arg1, struct varlena *arg2) ...@@ -301,10 +301,7 @@ text_lt(struct varlena *arg1, struct varlena *arg2)
int cval; int cval;
#endif #endif
int len; int len;
#ifdef UNSIGNED_CHAR_TEXT unsigned char *a1p, *a2p;
unsigned
#endif
char *a1p, *a2p;
if (arg1 == NULL || arg2 == NULL) if (arg1 == NULL || arg2 == NULL)
return((bool) FALSE); return((bool) FALSE);
...@@ -312,11 +309,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2) ...@@ -312,11 +309,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2)
len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ); len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ);
#ifdef USE_LOCALE #ifdef USE_LOCALE
if (!PointerIsValid(a1p = PALLOC(len+1)) a1p = (unsigned char *) palloc (len+1);
|| !PointerIsValid(a2p = PALLOC(len+1))) { a2p = (unsigned char *) palloc (len+1);
elog(WARN,"Unable to allocate memory for text comparison",NULL);
return(FALSE);
};
memcpy(a1p, VARDATA(arg1), len); memcpy(a1p, VARDATA(arg1), len);
*(a1p+len) = '\0'; *(a1p+len) = '\0';
...@@ -326,8 +320,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2) ...@@ -326,8 +320,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2)
cval = strcoll(a1p,a2p); cval = strcoll(a1p,a2p);
result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) < VARSIZE(arg2)))); result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) < VARSIZE(arg2))));
PFREE(a1p); pfree (a1p);
PFREE(a2p); pfree (a2p);
#else #else
a1p = (unsigned char *)VARDATA(arg1); a1p = (unsigned char *)VARDATA(arg1);
a2p = (unsigned char *)VARDATA(arg2); a2p = (unsigned char *)VARDATA(arg2);
...@@ -360,10 +354,7 @@ text_le(struct varlena *arg1, struct varlena *arg2) ...@@ -360,10 +354,7 @@ text_le(struct varlena *arg1, struct varlena *arg2)
int cval; int cval;
#endif #endif
int len; int len;
#ifdef UNSIGNED_CHAR_TEXT unsigned char *a1p, *a2p;
unsigned
#endif
char *a1p, *a2p;
if (arg1 == NULL || arg2 == NULL) if (arg1 == NULL || arg2 == NULL)
return((bool) 0); return((bool) 0);
...@@ -371,11 +362,8 @@ text_le(struct varlena *arg1, struct varlena *arg2) ...@@ -371,11 +362,8 @@ text_le(struct varlena *arg1, struct varlena *arg2)
len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ); len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ);
#ifdef USE_LOCALE #ifdef USE_LOCALE
if (!PointerIsValid(a1p = PALLOC(len+1)) a1p = (unsigned char *) palloc (len+1);
|| !PointerIsValid(a2p = PALLOC(len+1))) { a2p = (unsigned char *) palloc (len+1);
elog(WARN,"Unable to allocate memory for text comparison",NULL);
return(FALSE);
};
memcpy(a1p, VARDATA(arg1), len); memcpy(a1p, VARDATA(arg1), len);
*(a1p+len) = '\0'; *(a1p+len) = '\0';
...@@ -385,8 +373,8 @@ text_le(struct varlena *arg1, struct varlena *arg2) ...@@ -385,8 +373,8 @@ text_le(struct varlena *arg1, struct varlena *arg2)
cval = strcoll(a1p,a2p); cval = strcoll(a1p,a2p);
result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) <= VARSIZE(arg2)))); result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) <= VARSIZE(arg2))));
PFREE(a1p); pfree (a1p);
PFREE(a2p); pfree (a2p);
#else #else
a1p = (unsigned char *)VARDATA(arg1); a1p = (unsigned char *)VARDATA(arg1);
a2p = (unsigned char *)VARDATA(arg2); a2p = (unsigned char *)VARDATA(arg2);
......
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