aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varlena.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-08-26 17:40:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-08-26 17:40:36 +0000
commita9118fc5a8f5361fe31be0a040bd4160c2a7ea13 (patch)
tree5c0494dff3c7dc88c48e9894c6fabf3929a532f8 /src/backend/utils/adt/varlena.c
parent396526d8c341639d78eb1e79c027dd97ecdb4659 (diff)
downloadpostgresql-a9118fc5a8f5361fe31be0a040bd4160c2a7ea13.tar.gz
postgresql-a9118fc5a8f5361fe31be0a040bd4160c2a7ea13.zip
The idea of using _strncoll() on Windows doesn't work. Revert to same
code as we use on other platforms when encoding is not UTF8.
Diffstat (limited to 'src/backend/utils/adt/varlena.c')
-rw-r--r--src/backend/utils/adt/varlena.c67
1 files changed, 30 insertions, 37 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 3182b4eb801..d660e90b918 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.132 2005/08/24 17:50:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.133 2005/08/26 17:40:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -840,40 +840,22 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
* C. We also try to optimize relatively-short strings by avoiding
* palloc/pfree overhead.
*/
+ if (lc_collate_is_c())
+ {
+ result = strncmp(arg1, arg2, Min(len1, len2));
+ if ((result == 0) && (len1 != len2))
+ result = (len1 < len2) ? -1 : 1;
+ }
+ else
+ {
#define STACKBUFLEN 1024
- if (!lc_collate_is_c())
- {
char a1buf[STACKBUFLEN];
char a2buf[STACKBUFLEN];
char *a1p,
*a2p;
-#ifndef WIN32
-
- if (len1 >= STACKBUFLEN)
- a1p = (char *) palloc(len1 + 1);
- else
- a1p = a1buf;
- if (len2 >= STACKBUFLEN)
- a2p = (char *) palloc(len2 + 1);
- else
- a2p = a2buf;
-
- memcpy(a1p, arg1, len1);
- a1p[len1] = '\0';
- memcpy(a2p, arg2, len2);
- a2p[len2] = '\0';
-
- result = strcoll(a1p, a2p);
-
- if (a1p != a1buf)
- pfree(a1p);
- if (a2p != a2buf)
- pfree(a2p);
-
-#else /* WIN32 */
-
+#ifdef WIN32
/* Win32 does not have UTF-8, so we need to map to UTF-16 */
if (GetDatabaseEncoding() == PG_UTF8)
{
@@ -943,17 +925,28 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
return result;
}
+#endif /* WIN32 */
- /* Win32 has strncoll(), so use it to avoid copying */
- return _strncoll(arg1, arg2, Min(len1, len2));
+ if (len1 >= STACKBUFLEN)
+ a1p = (char *) palloc(len1 + 1);
+ else
+ a1p = a1buf;
+ if (len2 >= STACKBUFLEN)
+ a2p = (char *) palloc(len2 + 1);
+ else
+ a2p = a2buf;
-#endif /* WIN32 */
- }
- else
- {
- result = strncmp(arg1, arg2, Min(len1, len2));
- if ((result == 0) && (len1 != len2))
- result = (len1 < len2) ? -1 : 1;
+ memcpy(a1p, arg1, len1);
+ a1p[len1] = '\0';
+ memcpy(a2p, arg2, len2);
+ a2p[len2] = '\0';
+
+ result = strcoll(a1p, a2p);
+
+ if (a1p != a1buf)
+ pfree(a1p);
+ if (a2p != a2buf)
+ pfree(a2p);
}
return result;