Lexicographically compare 'char' and 'text'.
This commit is contained in:
parent
dee872de5c
commit
0346ab7175
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
|
||||
bool chareq(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 charle(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); }
|
||||
#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 charmi(int8 arg1, int8 arg2) { return(arg1 - arg2); }
|
||||
int8 charmul(int8 arg1, int8 arg2) { return(arg1 * arg2); }
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
int cval;
|
||||
#endif
|
||||
int len;
|
||||
#ifdef UNSIGNED_CHAR_TEXT
|
||||
unsigned
|
||||
#endif
|
||||
char *a1p, *a2p;
|
||||
unsigned char *a1p, *a2p;
|
||||
|
||||
if (arg1 == NULL || arg2 == NULL)
|
||||
return((bool) FALSE);
|
||||
@ -312,11 +309,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2)
|
||||
len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ);
|
||||
|
||||
#ifdef USE_LOCALE
|
||||
if (!PointerIsValid(a1p = PALLOC(len+1))
|
||||
|| !PointerIsValid(a2p = PALLOC(len+1))) {
|
||||
elog(WARN,"Unable to allocate memory for text comparison",NULL);
|
||||
return(FALSE);
|
||||
};
|
||||
a1p = (unsigned char *) palloc (len+1);
|
||||
a2p = (unsigned char *) palloc (len+1);
|
||||
|
||||
memcpy(a1p, VARDATA(arg1), len);
|
||||
*(a1p+len) = '\0';
|
||||
@ -326,8 +320,8 @@ text_lt(struct varlena *arg1, struct varlena *arg2)
|
||||
cval = strcoll(a1p,a2p);
|
||||
result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) < VARSIZE(arg2))));
|
||||
|
||||
PFREE(a1p);
|
||||
PFREE(a2p);
|
||||
pfree (a1p);
|
||||
pfree (a2p);
|
||||
#else
|
||||
a1p = (unsigned char *)VARDATA(arg1);
|
||||
a2p = (unsigned char *)VARDATA(arg2);
|
||||
@ -360,10 +354,7 @@ text_le(struct varlena *arg1, struct varlena *arg2)
|
||||
int cval;
|
||||
#endif
|
||||
int len;
|
||||
#ifdef UNSIGNED_CHAR_TEXT
|
||||
unsigned
|
||||
#endif
|
||||
char *a1p, *a2p;
|
||||
unsigned char *a1p, *a2p;
|
||||
|
||||
if (arg1 == NULL || arg2 == NULL)
|
||||
return((bool) 0);
|
||||
@ -371,11 +362,8 @@ text_le(struct varlena *arg1, struct varlena *arg2)
|
||||
len = (((VARSIZE(arg1) <= VARSIZE(arg2))? VARSIZE(arg1): VARSIZE(arg2))-VARHDRSZ);
|
||||
|
||||
#ifdef USE_LOCALE
|
||||
if (!PointerIsValid(a1p = PALLOC(len+1))
|
||||
|| !PointerIsValid(a2p = PALLOC(len+1))) {
|
||||
elog(WARN,"Unable to allocate memory for text comparison",NULL);
|
||||
return(FALSE);
|
||||
};
|
||||
a1p = (unsigned char *) palloc (len+1);
|
||||
a2p = (unsigned char *) palloc (len+1);
|
||||
|
||||
memcpy(a1p, VARDATA(arg1), len);
|
||||
*(a1p+len) = '\0';
|
||||
@ -385,8 +373,8 @@ text_le(struct varlena *arg1, struct varlena *arg2)
|
||||
cval = strcoll(a1p,a2p);
|
||||
result = ((cval < 0) || ((cval == 0) && (VARSIZE(arg1) <= VARSIZE(arg2))));
|
||||
|
||||
PFREE(a1p);
|
||||
PFREE(a2p);
|
||||
pfree (a1p);
|
||||
pfree (a2p);
|
||||
#else
|
||||
a1p = (unsigned char *)VARDATA(arg1);
|
||||
a2p = (unsigned char *)VARDATA(arg2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user