Solve the 'Turkish problem' with undesirable locale behavior for case

conversion of basic ASCII letters.  Remove all uses of strcasecmp and
strncasecmp in favor of new functions pg_strcasecmp and pg_strncasecmp;
remove most but not all direct uses of toupper and tolower in favor of
pg_toupper and pg_tolower.  These functions use the same notions of
case folding already developed for identifier case conversion.  I left
the straight locale-based folding in place for situations where we are
just manipulating user data and not trying to match it to built-in
strings --- for example, the SQL upper() function is still locale
dependent.  Perhaps this will prove not to be what's wanted, but at
the moment we can initdb and pass regression tests in Turkish locale.
This commit is contained in:
Tom Lane 2004-05-07 00:24:59 +00:00
parent 4d46274b33
commit 0bd61548ab
67 changed files with 820 additions and 923 deletions

3
configure vendored
View File

@ -11744,8 +11744,7 @@ fi
for ac_func in crypt fseeko getopt getrusage inet_aton random rint srandom strdup strerror strtol strtoul unsetenv
for ac_func in crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul unsetenv
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.344 2004/05/05 21:18:29 tgl Exp $ dnl $PostgreSQL: pgsql/configure.in,v 1.345 2004/05/07 00:24:57 tgl Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
@ -858,7 +858,7 @@ else
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break]) AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi fi
AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul unsetenv]) AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strdup strerror strtol strtoul unsetenv])
# system's version of getaddrinfo(), if any, may be used only if we found # system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h

View File

@ -91,7 +91,7 @@ checkLevel(lquery_level * curq, ltree_level * curt)
for (i = 0; i < curq->numvar; i++) for (i = 0; i < curq->numvar; i++)
{ {
cmpptr = (curvar->flag & LVAR_INCASE) ? strncasecmp : strncmp; cmpptr = (curvar->flag & LVAR_INCASE) ? pg_strncasecmp : strncmp;
if (curvar->flag & LVAR_SUBLEXEM) if (curvar->flag & LVAR_SUBLEXEM)
{ {

View File

@ -54,7 +54,7 @@ checkcondition_str(void *checkval, ITEM * val)
char *op = ((CHKVAL *) checkval)->operand + val->distance; char *op = ((CHKVAL *) checkval)->operand + val->distance;
int (*cmpptr) (const char *, const char *, size_t); int (*cmpptr) (const char *, const char *, size_t);
cmpptr = (val->flag & LVAR_INCASE) ? strncasecmp : strncmp; cmpptr = (val->flag & LVAR_INCASE) ? pg_strncasecmp : strncmp;
while (tlen > 0) while (tlen > 0)
{ {
if (val->flag & LVAR_SUBLEXEM) if (val->flag & LVAR_SUBLEXEM)

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.12 2003/11/29 22:39:28 pgsql Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.13 2004/05/07 00:24:57 tgl Exp $
*/ */
@ -561,7 +561,7 @@ px_find_digest(const char *name, PX_MD ** res)
PX_MD *h; PX_MD *h;
for (p = int_digest_list; p->name; p++) for (p = int_digest_list; p->name; p++)
if (!strcasecmp(p->name, name)) if (pg_strcasecmp(p->name, name) == 0)
{ {
h = px_alloc(sizeof(*h)); h = px_alloc(sizeof(*h));
p->init(h); p->init(h);

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.10 2003/11/29 22:39:28 pgsql Exp $ */ /* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.11 2004/05/07 00:24:57 tgl Exp $ */
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */ /* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
/* /*
@ -141,7 +141,7 @@ md5_init(md5_ctxt * ctxt)
ctxt->md5_stb = MD5_B0; ctxt->md5_stb = MD5_B0;
ctxt->md5_stc = MD5_C0; ctxt->md5_stc = MD5_C0;
ctxt->md5_std = MD5_D0; ctxt->md5_std = MD5_D0;
bzero(ctxt->md5_buf, sizeof(ctxt->md5_buf)); memset(ctxt->md5_buf, 0, sizeof(ctxt->md5_buf));
} }
void void

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/mhash.c,v 1.9 2003/11/29 22:39:28 pgsql Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/mhash.c,v 1.10 2004/05/07 00:24:57 tgl Exp $
*/ */
#include <postgres.h> #include <postgres.h>
@ -217,9 +217,9 @@ find_hashid(const char *name)
mname = mhash_get_hash_name(i); mname = mhash_get_hash_name(i);
if (mname == NULL) if (mname == NULL)
continue; continue;
b = strcasecmp(name, mname); b = pg_strcasecmp(name, mname);
free(mname); free(mname);
if (!b) if (b == 0)
{ {
res = i; res = i;
break; break;
@ -312,7 +312,7 @@ px_find_cipher(const char *name, PX_Cipher ** res)
PX_Cipher *c; PX_Cipher *c;
strcpy(nbuf, name); StrNCpy(nbuf, name, sizeof(nbuf));
if ((p = strrchr(nbuf, '-')) != NULL) if ((p = strrchr(nbuf, '-')) != NULL)
{ {

View File

@ -26,13 +26,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.15 2003/11/29 22:39:28 pgsql Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.16 2004/05/07 00:24:57 tgl Exp $
*/ */
#include <postgres.h> #include "postgres.h"
#include <fmgr.h>
#include <ctype.h> #include <ctype.h>
#include "fmgr.h"
#include "parser/scansup.h"
#include "px.h" #include "px.h"
#include "px-crypt.h" #include "px-crypt.h"
#include "pgcrypto.h" #include "pgcrypto.h"
@ -554,26 +557,12 @@ find_provider(text *name,
char *desc, int silent) char *desc, int silent)
{ {
void *res; void *res;
char buf[PX_MAX_NAMELEN + 1], char *buf;
*p;
unsigned len;
unsigned i;
int err; int err;
len = VARSIZE(name) - VARHDRSZ; buf = downcase_truncate_identifier(VARDATA(name),
if (len > PX_MAX_NAMELEN) VARSIZE(name) - VARHDRSZ,
{ false);
if (silent)
return NULL;
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("%s type does not exist (name too long)", desc)));
}
p = VARDATA(name);
for (i = 0; i < len; i++)
buf[i] = tolower((unsigned char) p[i]);
buf[len] = 0;
err = provider_lookup(buf, &res); err = provider_lookup(buf, &res);
@ -582,5 +571,7 @@ find_provider(text *name,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("%s type does not exist: \"%s\"", desc, buf))); errmsg("%s type does not exist: \"%s\"", desc, buf)));
pfree(buf);
return err ? NULL : res; return err ? NULL : res;
} }

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.7 2003/11/29 22:39:28 pgsql Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.8 2004/05/07 00:24:57 tgl Exp $
*/ */
#include <postgres.h> #include <postgres.h>
@ -170,7 +170,7 @@ px_gen_salt(const char *salt_type, char *buf, int rounds)
for (i = 0; gen_list[i].name; i++) for (i = 0; gen_list[i].name; i++)
{ {
g = &gen_list[i]; g = &gen_list[i];
if (strcasecmp(g->name, salt_type) != 0) if (pg_strcasecmp(g->name, salt_type) != 0)
continue; continue;
if (g->def_rounds) if (g->def_rounds)

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.8 2003/11/29 22:39:28 pgsql Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.9 2004/05/07 00:24:57 tgl Exp $
*/ */
#include <postgres.h> #include <postgres.h>
@ -39,7 +39,7 @@ px_resolve_alias(const PX_Alias * list, const char *name)
{ {
while (list->name) while (list->name)
{ {
if (!strcasecmp(list->alias, name)) if (pg_strcasecmp(list->alias, name) == 0)
return list->name; return list->name;
list++; list++;
} }

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.12 2003/11/29 22:39:28 pgsql Exp $ */ /* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.13 2004/05/07 00:24:57 tgl Exp $ */
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/* /*
@ -227,7 +227,7 @@ sha1_step(struct sha1_ctxt * ctxt)
H(3) = H(3) + d; H(3) = H(3) + d;
H(4) = H(4) + e; H(4) = H(4) + e;
bzero(&ctxt->m.b8[0], 64); memset(&ctxt->m.b8[0], 0, 64);
} }
/*------------------------------------------------------------*/ /*------------------------------------------------------------*/
@ -235,7 +235,7 @@ sha1_step(struct sha1_ctxt * ctxt)
void void
sha1_init(struct sha1_ctxt * ctxt) sha1_init(struct sha1_ctxt * ctxt)
{ {
bzero(ctxt, sizeof(struct sha1_ctxt)); memset(ctxt, 0, sizeof(struct sha1_ctxt));
H(0) = 0x67452301; H(0) = 0x67452301;
H(1) = 0xefcdab89; H(1) = 0xefcdab89;
H(2) = 0x98badcfe; H(2) = 0x98badcfe;
@ -255,14 +255,14 @@ sha1_pad(struct sha1_ctxt * ctxt)
padlen = 64 - padstart; padlen = 64 - padstart;
if (padlen < 8) if (padlen < 8)
{ {
bzero(&ctxt->m.b8[padstart], padlen); memset(&ctxt->m.b8[padstart], 0, padlen);
COUNT += padlen; COUNT += padlen;
COUNT %= 64; COUNT %= 64;
sha1_step(ctxt); sha1_step(ctxt);
padstart = COUNT % 64; /* should be 0 */ padstart = COUNT % 64; /* should be 0 */
padlen = 64 - padstart; /* should be 64 */ padlen = 64 - padstart; /* should be 64 */
} }
bzero(&ctxt->m.b8[padstart], padlen - 8); memset(&ctxt->m.b8[padstart], 0, padlen - 8);
COUNT += (padlen - 8); COUNT += (padlen - 8);
COUNT %= 64; COUNT %= 64;
#if BYTE_ORDER == BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN

View File

@ -498,7 +498,7 @@ findTTStatus(char *name)
TTOffList *pp; TTOffList *pp;
for (pp = TTOff.next; pp; pp = pp->next) for (pp = TTOff.next; pp; pp = pp->next)
if (strcasecmp(name, pp->name) == 0) if (pg_strcasecmp(name, pp->name) == 0)
return 0; return 0;
return 1; return 1;
} }

View File

@ -62,7 +62,7 @@ spell_init(PG_FUNCTION_ARGS)
pcfg = cfg; pcfg = cfg;
while (pcfg->key) while (pcfg->key)
{ {
if (strcasecmp("DictFile", pcfg->key) == 0) if (pg_strcasecmp("DictFile", pcfg->key) == 0)
{ {
if (dictloaded) if (dictloaded)
{ {
@ -81,7 +81,7 @@ spell_init(PG_FUNCTION_ARGS)
} }
dictloaded = true; dictloaded = true;
} }
else if (strcasecmp("AffFile", pcfg->key) == 0) else if (pg_strcasecmp("AffFile", pcfg->key) == 0)
{ {
if (affloaded) if (affloaded)
{ {
@ -100,7 +100,7 @@ spell_init(PG_FUNCTION_ARGS)
} }
affloaded = true; affloaded = true;
} }
else if (strcasecmp("StopFile", pcfg->key) == 0) else if (pg_strcasecmp("StopFile", pcfg->key) == 0)
{ {
text *tmp = char2text(pcfg->value); text *tmp = char2text(pcfg->value);

View File

@ -10,7 +10,7 @@
#define MAX_NORM 1024 #define MAX_NORM 1024
#define MAXNORMLEN 256 #define MAXNORMLEN 256
#define STRNCASECMP(x,y) (strncasecmp(x,y,strlen(y))) #define STRNCASECMP(x,y) pg_strncasecmp(x, y, strlen(y))
#define GETWCHAR(W,L,N,T) ( ((uint8*)(W))[ ((T)=='p') ? (N) : ( (L) - 1 - (N) ) ] ) #define GETWCHAR(W,L,N,T) ( ((uint8*)(W))[ ((T)=='p') ? (N) : ( (L) - 1 - (N) ) ] )
#define GETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T ) #define GETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T )
@ -304,19 +304,19 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
continue; continue;
} }
} }
if (!STRNCASECMP(str, "suffixes")) if (STRNCASECMP(str, "suffixes")==0)
{ {
suffixes = 1; suffixes = 1;
prefixes = 0; prefixes = 0;
continue; continue;
} }
if (!STRNCASECMP(str, "prefixes")) if (STRNCASECMP(str, "prefixes")==0)
{ {
suffixes = 0; suffixes = 0;
prefixes = 1; prefixes = 1;
continue; continue;
} }
if (!STRNCASECMP(str, "flag ")) if (STRNCASECMP(str, "flag ")==0)
{ {
s = str + 5; s = str + 5;
flagflags=0; flagflags=0;

View File

@ -210,15 +210,15 @@ prsd_headline(PG_FUNCTION_ARGS)
while (mptr && mptr->key) while (mptr && mptr->key)
{ {
if (strcasecmp(mptr->key, "MaxWords") == 0) if (pg_strcasecmp(mptr->key, "MaxWords") == 0)
max_words = pg_atoi(mptr->value, 4, 1); max_words = pg_atoi(mptr->value, 4, 1);
else if (strcasecmp(mptr->key, "MinWords") == 0) else if (pg_strcasecmp(mptr->key, "MinWords") == 0)
min_words = pg_atoi(mptr->value, 4, 1); min_words = pg_atoi(mptr->value, 4, 1);
else if (strcasecmp(mptr->key, "ShortWord") == 0) else if (pg_strcasecmp(mptr->key, "ShortWord") == 0)
shortword = pg_atoi(mptr->value, 4, 1); shortword = pg_atoi(mptr->value, 4, 1);
else if (strcasecmp(mptr->key, "StartSel") == 0) else if (pg_strcasecmp(mptr->key, "StartSel") == 0)
prs->startsel = pstrdup(mptr->value); prs->startsel = pstrdup(mptr->value);
else if (strcasecmp(mptr->key, "StopSel") == 0) else if (pg_strcasecmp(mptr->key, "StopSel") == 0)
prs->stopsel = pstrdup(mptr->value); prs->stopsel = pstrdup(mptr->value);
pfree(mptr->key); pfree(mptr->key);

View File

@ -1,5 +1,5 @@
# -*-makefile-*- # -*-makefile-*-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.180 2004/04/30 15:01:25 momjian Exp $ # $PostgreSQL: pgsql/src/Makefile.global.in,v 1.181 2004/05/07 00:24:57 tgl Exp $
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets, # All PostgreSQL makefiles include this file and use the variables it sets,
@ -339,7 +339,7 @@ endif
# #
# substitute implementations of the C library # substitute implementations of the C library
LIBOBJS = @LIBOBJS@ noblock.o path.o pgsleep.o sprompt.o thread.o LIBOBJS = @LIBOBJS@ noblock.o path.o pgsleep.o pgstrcasecmp.o sprompt.o thread.o
ifneq (,$(LIBOBJS)) ifneq (,$(LIBOBJS))
LIBS += -lpgport LIBS += -lpgport

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.140 2004/05/07 00:24:57 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3778,27 +3778,27 @@ assign_xlog_sync_method(const char *method, bool doit, GucSource source)
int new_sync_method; int new_sync_method;
int new_sync_bit; int new_sync_bit;
if (strcasecmp(method, "fsync") == 0) if (pg_strcasecmp(method, "fsync") == 0)
{ {
new_sync_method = SYNC_METHOD_FSYNC; new_sync_method = SYNC_METHOD_FSYNC;
new_sync_bit = 0; new_sync_bit = 0;
} }
#ifdef HAVE_FDATASYNC #ifdef HAVE_FDATASYNC
else if (strcasecmp(method, "fdatasync") == 0) else if (pg_strcasecmp(method, "fdatasync") == 0)
{ {
new_sync_method = SYNC_METHOD_FDATASYNC; new_sync_method = SYNC_METHOD_FDATASYNC;
new_sync_bit = 0; new_sync_bit = 0;
} }
#endif #endif
#ifdef OPEN_SYNC_FLAG #ifdef OPEN_SYNC_FLAG
else if (strcasecmp(method, "open_sync") == 0) else if (pg_strcasecmp(method, "open_sync") == 0)
{ {
new_sync_method = SYNC_METHOD_OPEN; new_sync_method = SYNC_METHOD_OPEN;
new_sync_bit = OPEN_SYNC_FLAG; new_sync_bit = OPEN_SYNC_FLAG;
} }
#endif #endif
#ifdef OPEN_DATASYNC_FLAG #ifdef OPEN_DATASYNC_FLAG
else if (strcasecmp(method, "open_datasync") == 0) else if (pg_strcasecmp(method, "open_datasync") == 0)
{ {
new_sync_method = SYNC_METHOD_OPEN; new_sync_method = SYNC_METHOD_OPEN;
new_sync_bit = OPEN_DATASYNC_FLAG; new_sync_bit = OPEN_DATASYNC_FLAG;

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.16 2003/11/29 19:51:47 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.17 2004/05/07 00:24:57 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
@ -75,21 +75,21 @@ DefineAggregate(List *names, List *parameters)
* sfunc1, stype1, and initcond1 are accepted as obsolete * sfunc1, stype1, and initcond1 are accepted as obsolete
* spellings for sfunc, stype, initcond. * spellings for sfunc, stype, initcond.
*/ */
if (strcasecmp(defel->defname, "sfunc") == 0) if (pg_strcasecmp(defel->defname, "sfunc") == 0)
transfuncName = defGetQualifiedName(defel); transfuncName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "sfunc1") == 0) else if (pg_strcasecmp(defel->defname, "sfunc1") == 0)
transfuncName = defGetQualifiedName(defel); transfuncName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "finalfunc") == 0) else if (pg_strcasecmp(defel->defname, "finalfunc") == 0)
finalfuncName = defGetQualifiedName(defel); finalfuncName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "basetype") == 0) else if (pg_strcasecmp(defel->defname, "basetype") == 0)
baseType = defGetTypeName(defel); baseType = defGetTypeName(defel);
else if (strcasecmp(defel->defname, "stype") == 0) else if (pg_strcasecmp(defel->defname, "stype") == 0)
transType = defGetTypeName(defel); transType = defGetTypeName(defel);
else if (strcasecmp(defel->defname, "stype1") == 0) else if (pg_strcasecmp(defel->defname, "stype1") == 0)
transType = defGetTypeName(defel); transType = defGetTypeName(defel);
else if (strcasecmp(defel->defname, "initcond") == 0) else if (pg_strcasecmp(defel->defname, "initcond") == 0)
initval = defGetString(defel); initval = defGetString(defel);
else if (strcasecmp(defel->defname, "initcond1") == 0) else if (pg_strcasecmp(defel->defname, "initcond1") == 0)
initval = defGetString(defel); initval = defGetString(defel);
else else
ereport(WARNING, ereport(WARNING,
@ -124,7 +124,7 @@ DefineAggregate(List *names, List *parameters)
* be able to store values of the transtype. However, we can allow * be able to store values of the transtype. However, we can allow
* polymorphic transtype in some cases (AggregateCreate will check). * polymorphic transtype in some cases (AggregateCreate will check).
*/ */
if (strcasecmp(TypeNameToString(baseType), "ANY") == 0) if (pg_strcasecmp(TypeNameToString(baseType), "ANY") == 0)
baseTypeId = ANYOID; baseTypeId = ANYOID;
else else
baseTypeId = typenameTypeId(baseType); baseTypeId = typenameTypeId(baseType);

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.86 2004/02/21 00:34:52 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.87 2004/05/07 00:24:57 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
@ -240,12 +240,12 @@ defGetTypeLength(DefElem *def)
def->defname))); def->defname)));
break; break;
case T_String: case T_String:
if (strcasecmp(strVal(def->arg), "variable") == 0) if (pg_strcasecmp(strVal(def->arg), "variable") == 0)
return -1; /* variable length */ return -1; /* variable length */
break; break;
case T_TypeName: case T_TypeName:
/* cope if grammar chooses to believe "variable" is a typename */ /* cope if grammar chooses to believe "variable" is a typename */
if (strcasecmp(TypeNameToString((TypeName *) def->arg), if (pg_strcasecmp(TypeNameToString((TypeName *) def->arg),
"variable") == 0) "variable") == 0)
return -1; /* variable length */ return -1; /* variable length */
break; break;

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.44 2004/02/21 00:34:52 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.45 2004/05/07 00:24:57 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* These routines take the parse tree and pick out the * These routines take the parse tree and pick out the
@ -328,9 +328,9 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
{ {
DefElem *param = (DefElem *) lfirst(pl); DefElem *param = (DefElem *) lfirst(pl);
if (strcasecmp(param->defname, "isstrict") == 0) if (pg_strcasecmp(param->defname, "isstrict") == 0)
*isStrict_p = true; *isStrict_p = true;
else if (strcasecmp(param->defname, "iscachable") == 0) else if (pg_strcasecmp(param->defname, "iscachable") == 0)
{ {
/* obsolete spelling of isImmutable */ /* obsolete spelling of isImmutable */
*volatility_p = PROVOLATILE_IMMUTABLE; *volatility_p = PROVOLATILE_IMMUTABLE;

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.13 2003/11/29 19:51:47 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.14 2004/05/07 00:24:57 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
@ -97,7 +97,7 @@ DefineOperator(List *names, List *parameters)
{ {
DefElem *defel = (DefElem *) lfirst(pl); DefElem *defel = (DefElem *) lfirst(pl);
if (strcasecmp(defel->defname, "leftarg") == 0) if (pg_strcasecmp(defel->defname, "leftarg") == 0)
{ {
typeName1 = defGetTypeName(defel); typeName1 = defGetTypeName(defel);
if (typeName1->setof) if (typeName1->setof)
@ -105,7 +105,7 @@ DefineOperator(List *names, List *parameters)
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("setof type not allowed for operator argument"))); errmsg("setof type not allowed for operator argument")));
} }
else if (strcasecmp(defel->defname, "rightarg") == 0) else if (pg_strcasecmp(defel->defname, "rightarg") == 0)
{ {
typeName2 = defGetTypeName(defel); typeName2 = defGetTypeName(defel);
if (typeName2->setof) if (typeName2->setof)
@ -113,27 +113,27 @@ DefineOperator(List *names, List *parameters)
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("setof type not allowed for operator argument"))); errmsg("setof type not allowed for operator argument")));
} }
else if (strcasecmp(defel->defname, "procedure") == 0) else if (pg_strcasecmp(defel->defname, "procedure") == 0)
functionName = defGetQualifiedName(defel); functionName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "commutator") == 0) else if (pg_strcasecmp(defel->defname, "commutator") == 0)
commutatorName = defGetQualifiedName(defel); commutatorName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "negator") == 0) else if (pg_strcasecmp(defel->defname, "negator") == 0)
negatorName = defGetQualifiedName(defel); negatorName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "restrict") == 0) else if (pg_strcasecmp(defel->defname, "restrict") == 0)
restrictionName = defGetQualifiedName(defel); restrictionName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "join") == 0) else if (pg_strcasecmp(defel->defname, "join") == 0)
joinName = defGetQualifiedName(defel); joinName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "hashes") == 0) else if (pg_strcasecmp(defel->defname, "hashes") == 0)
canHash = TRUE; canHash = TRUE;
else if (strcasecmp(defel->defname, "merges") == 0) else if (pg_strcasecmp(defel->defname, "merges") == 0)
canMerge = TRUE; canMerge = TRUE;
else if (strcasecmp(defel->defname, "sort1") == 0) else if (pg_strcasecmp(defel->defname, "sort1") == 0)
leftSortName = defGetQualifiedName(defel); leftSortName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "sort2") == 0) else if (pg_strcasecmp(defel->defname, "sort2") == 0)
rightSortName = defGetQualifiedName(defel); rightSortName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "ltcmp") == 0) else if (pg_strcasecmp(defel->defname, "ltcmp") == 0)
ltCompareName = defGetQualifiedName(defel); ltCompareName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "gtcmp") == 0) else if (pg_strcasecmp(defel->defname, "gtcmp") == 0)
gtCompareName = defGetQualifiedName(defel); gtCompareName = defGetQualifiedName(defel);
else else
ereport(WARNING, ereport(WARNING,

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.104 2004/05/06 16:10:57 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.105 2004/05/07 00:24:57 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3126,13 +3126,13 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue)
Assert(IsA(newValue, String)); Assert(IsA(newValue, String));
storagemode = strVal(newValue); storagemode = strVal(newValue);
if (strcasecmp(storagemode, "plain") == 0) if (pg_strcasecmp(storagemode, "plain") == 0)
newstorage = 'p'; newstorage = 'p';
else if (strcasecmp(storagemode, "external") == 0) else if (pg_strcasecmp(storagemode, "external") == 0)
newstorage = 'e'; newstorage = 'e';
else if (strcasecmp(storagemode, "extended") == 0) else if (pg_strcasecmp(storagemode, "extended") == 0)
newstorage = 'x'; newstorage = 'x';
else if (strcasecmp(storagemode, "main") == 0) else if (pg_strcasecmp(storagemode, "main") == 0)
newstorage = 'm'; newstorage = 'm';
else else
{ {

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.54 2004/05/05 17:06:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.55 2004/05/07 00:24:57 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
@ -142,28 +142,28 @@ DefineType(List *names, List *parameters)
{ {
DefElem *defel = (DefElem *) lfirst(pl); DefElem *defel = (DefElem *) lfirst(pl);
if (strcasecmp(defel->defname, "internallength") == 0) if (pg_strcasecmp(defel->defname, "internallength") == 0)
internalLength = defGetTypeLength(defel); internalLength = defGetTypeLength(defel);
else if (strcasecmp(defel->defname, "externallength") == 0) else if (pg_strcasecmp(defel->defname, "externallength") == 0)
; /* ignored -- remove after 7.3 */ ; /* ignored -- remove after 7.3 */
else if (strcasecmp(defel->defname, "input") == 0) else if (pg_strcasecmp(defel->defname, "input") == 0)
inputName = defGetQualifiedName(defel); inputName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "output") == 0) else if (pg_strcasecmp(defel->defname, "output") == 0)
outputName = defGetQualifiedName(defel); outputName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "receive") == 0) else if (pg_strcasecmp(defel->defname, "receive") == 0)
receiveName = defGetQualifiedName(defel); receiveName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "send") == 0) else if (pg_strcasecmp(defel->defname, "send") == 0)
sendName = defGetQualifiedName(defel); sendName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "analyze") == 0 || else if (pg_strcasecmp(defel->defname, "analyze") == 0 ||
strcasecmp(defel->defname, "analyse") == 0) pg_strcasecmp(defel->defname, "analyse") == 0)
analyzeName = defGetQualifiedName(defel); analyzeName = defGetQualifiedName(defel);
else if (strcasecmp(defel->defname, "delimiter") == 0) else if (pg_strcasecmp(defel->defname, "delimiter") == 0)
{ {
char *p = defGetString(defel); char *p = defGetString(defel);
delimiter = p[0]; delimiter = p[0];
} }
else if (strcasecmp(defel->defname, "element") == 0) else if (pg_strcasecmp(defel->defname, "element") == 0)
{ {
elemType = typenameTypeId(defGetTypeName(defel)); elemType = typenameTypeId(defGetTypeName(defel));
/* disallow arrays of pseudotypes */ /* disallow arrays of pseudotypes */
@ -173,11 +173,11 @@ DefineType(List *names, List *parameters)
errmsg("array element type cannot be %s", errmsg("array element type cannot be %s",
format_type_be(elemType)))); format_type_be(elemType))));
} }
else if (strcasecmp(defel->defname, "default") == 0) else if (pg_strcasecmp(defel->defname, "default") == 0)
defaultValue = defGetString(defel); defaultValue = defGetString(defel);
else if (strcasecmp(defel->defname, "passedbyvalue") == 0) else if (pg_strcasecmp(defel->defname, "passedbyvalue") == 0)
byValue = true; byValue = true;
else if (strcasecmp(defel->defname, "alignment") == 0) else if (pg_strcasecmp(defel->defname, "alignment") == 0)
{ {
char *a = defGetString(defel); char *a = defGetString(defel);
@ -187,35 +187,35 @@ DefineType(List *names, List *parameters)
* recognize translated type names as well as the nominal * recognize translated type names as well as the nominal
* form. * form.
*/ */
if (strcasecmp(a, "double") == 0 || if (pg_strcasecmp(a, "double") == 0 ||
strcasecmp(a, "float8") == 0 || pg_strcasecmp(a, "float8") == 0 ||
strcasecmp(a, "pg_catalog.float8") == 0) pg_strcasecmp(a, "pg_catalog.float8") == 0)
alignment = 'd'; alignment = 'd';
else if (strcasecmp(a, "int4") == 0 || else if (pg_strcasecmp(a, "int4") == 0 ||
strcasecmp(a, "pg_catalog.int4") == 0) pg_strcasecmp(a, "pg_catalog.int4") == 0)
alignment = 'i'; alignment = 'i';
else if (strcasecmp(a, "int2") == 0 || else if (pg_strcasecmp(a, "int2") == 0 ||
strcasecmp(a, "pg_catalog.int2") == 0) pg_strcasecmp(a, "pg_catalog.int2") == 0)
alignment = 's'; alignment = 's';
else if (strcasecmp(a, "char") == 0 || else if (pg_strcasecmp(a, "char") == 0 ||
strcasecmp(a, "pg_catalog.bpchar") == 0) pg_strcasecmp(a, "pg_catalog.bpchar") == 0)
alignment = 'c'; alignment = 'c';
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("alignment \"%s\" not recognized", a))); errmsg("alignment \"%s\" not recognized", a)));
} }
else if (strcasecmp(defel->defname, "storage") == 0) else if (pg_strcasecmp(defel->defname, "storage") == 0)
{ {
char *a = defGetString(defel); char *a = defGetString(defel);
if (strcasecmp(a, "plain") == 0) if (pg_strcasecmp(a, "plain") == 0)
storage = 'p'; storage = 'p';
else if (strcasecmp(a, "external") == 0) else if (pg_strcasecmp(a, "external") == 0)
storage = 'e'; storage = 'e';
else if (strcasecmp(a, "extended") == 0) else if (pg_strcasecmp(a, "extended") == 0)
storage = 'x'; storage = 'x';
else if (strcasecmp(a, "main") == 0) else if (pg_strcasecmp(a, "main") == 0)
storage = 'm'; storage = 'm';
else else
ereport(ERROR, ereport(ERROR,

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.93 2004/01/19 19:04:40 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.94 2004/05/07 00:24:57 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -23,6 +23,7 @@
#include "catalog/pg_shadow.h" #include "catalog/pg_shadow.h"
#include "commands/variable.h" #include "commands/variable.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/scansup.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/syscache.h" #include "utils/syscache.h"
@ -82,22 +83,22 @@ assign_datestyle(const char *value, bool doit, GucSource source)
/* Ugh. Somebody ought to write a table driven version -- mjl */ /* Ugh. Somebody ought to write a table driven version -- mjl */
if (strcasecmp(tok, "ISO") == 0) if (pg_strcasecmp(tok, "ISO") == 0)
{ {
newDateStyle = USE_ISO_DATES; newDateStyle = USE_ISO_DATES;
scnt++; scnt++;
} }
else if (strcasecmp(tok, "SQL") == 0) else if (pg_strcasecmp(tok, "SQL") == 0)
{ {
newDateStyle = USE_SQL_DATES; newDateStyle = USE_SQL_DATES;
scnt++; scnt++;
} }
else if (strncasecmp(tok, "POSTGRES", 8) == 0) else if (pg_strncasecmp(tok, "POSTGRES", 8) == 0)
{ {
newDateStyle = USE_POSTGRES_DATES; newDateStyle = USE_POSTGRES_DATES;
scnt++; scnt++;
} }
else if (strcasecmp(tok, "GERMAN") == 0) else if (pg_strcasecmp(tok, "GERMAN") == 0)
{ {
newDateStyle = USE_GERMAN_DATES; newDateStyle = USE_GERMAN_DATES;
scnt++; scnt++;
@ -105,25 +106,25 @@ assign_datestyle(const char *value, bool doit, GucSource source)
if (ocnt == 0) if (ocnt == 0)
newDateOrder = DATEORDER_DMY; newDateOrder = DATEORDER_DMY;
} }
else if (strcasecmp(tok, "YMD") == 0) else if (pg_strcasecmp(tok, "YMD") == 0)
{ {
newDateOrder = DATEORDER_YMD; newDateOrder = DATEORDER_YMD;
ocnt++; ocnt++;
} }
else if (strcasecmp(tok, "DMY") == 0 || else if (pg_strcasecmp(tok, "DMY") == 0 ||
strncasecmp(tok, "EURO", 4) == 0) pg_strncasecmp(tok, "EURO", 4) == 0)
{ {
newDateOrder = DATEORDER_DMY; newDateOrder = DATEORDER_DMY;
ocnt++; ocnt++;
} }
else if (strcasecmp(tok, "MDY") == 0 || else if (pg_strcasecmp(tok, "MDY") == 0 ||
strcasecmp(tok, "US") == 0 || pg_strcasecmp(tok, "US") == 0 ||
strncasecmp(tok, "NONEURO", 7) == 0) pg_strncasecmp(tok, "NONEURO", 7) == 0)
{ {
newDateOrder = DATEORDER_MDY; newDateOrder = DATEORDER_MDY;
ocnt++; ocnt++;
} }
else if (strcasecmp(tok, "DEFAULT") == 0) else if (pg_strcasecmp(tok, "DEFAULT") == 0)
{ {
/* /*
* Easiest way to get the current DEFAULT state is to fetch * Easiest way to get the current DEFAULT state is to fetch
@ -321,8 +322,7 @@ clear_tz(void)
static bool static bool
tzset_succeeded(const char *tz) tzset_succeeded(const char *tz)
{ {
char tztmp[TZBUF_LEN]; char *tztmp;
char *cp;
int tzval; int tzval;
/* /*
@ -339,9 +339,7 @@ tzset_succeeded(const char *tz)
* Check for known spellings of "UTC". Note we must downcase the * Check for known spellings of "UTC". Note we must downcase the
* input before passing it to DecodePosixTimezone(). * input before passing it to DecodePosixTimezone().
*/ */
StrNCpy(tztmp, tz, sizeof(tztmp)); tztmp = downcase_truncate_identifier(tz, strlen(tz), false);
for (cp = tztmp; *cp; cp++)
*cp = tolower((unsigned char) *cp);
if (DecodePosixTimezone(tztmp, &tzval) == 0) if (DecodePosixTimezone(tztmp, &tzval) == 0)
if (tzval == 0) if (tzval == 0)
return true; return true;
@ -410,7 +408,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
/* /*
* Check for INTERVAL 'foo' * Check for INTERVAL 'foo'
*/ */
if (strncasecmp(value, "interval", 8) == 0) if (pg_strncasecmp(value, "interval", 8) == 0)
{ {
const char *valueptr = value; const char *valueptr = value;
char *val; char *val;
@ -474,7 +472,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
HasCTZSet = true; HasCTZSet = true;
} }
} }
else if (strcasecmp(value, "UNKNOWN") == 0) else if (pg_strcasecmp(value, "UNKNOWN") == 0)
{ {
/* /*
* UNKNOWN is the value shown as the "default" for TimeZone in * UNKNOWN is the value shown as the "default" for TimeZone in

View File

@ -47,7 +47,7 @@
* permission to use and distribute the software in accordance with the * permission to use and distribute the software in accordance with the
* terms specified in this license. * terms specified in this license.
* *
* $PostgreSQL: pgsql/src/backend/regex/regc_locale.c,v 1.5 2003/11/29 19:51:55 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/regex/regc_locale.c,v 1.6 2004/05/07 00:24:57 tgl Exp $
*/ */
/* ASCII character-name table */ /* ASCII character-name table */
@ -353,61 +353,61 @@ static struct cname
* some ctype functions with non-ascii-char guard * some ctype functions with non-ascii-char guard
*/ */
static int static int
pg_isdigit(pg_wchar c) pg_wc_isdigit(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isdigit((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isdigit((unsigned char) c));
} }
static int static int
pg_isalpha(pg_wchar c) pg_wc_isalpha(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isalpha((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isalpha((unsigned char) c));
} }
static int static int
pg_isalnum(pg_wchar c) pg_wc_isalnum(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isalnum((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isalnum((unsigned char) c));
} }
static int static int
pg_isupper(pg_wchar c) pg_wc_isupper(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isupper((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isupper((unsigned char) c));
} }
static int static int
pg_islower(pg_wchar c) pg_wc_islower(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && islower((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && islower((unsigned char) c));
} }
static int static int
pg_isgraph(pg_wchar c) pg_wc_isgraph(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c));
} }
static int static int
pg_isprint(pg_wchar c) pg_wc_isprint(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c));
} }
static int static int
pg_ispunct(pg_wchar c) pg_wc_ispunct(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && ispunct((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && ispunct((unsigned char) c));
} }
static int static int
pg_isspace(pg_wchar c) pg_wc_isspace(pg_wchar c)
{ {
return (c >= 0 && c <= UCHAR_MAX && isspace((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isspace((unsigned char) c));
} }
static pg_wchar static pg_wchar
pg_toupper(pg_wchar c) pg_wc_toupper(pg_wchar c)
{ {
if (c >= 0 && c <= UCHAR_MAX) if (c >= 0 && c <= UCHAR_MAX)
return toupper((unsigned char) c); return toupper((unsigned char) c);
@ -415,7 +415,7 @@ pg_toupper(pg_wchar c)
} }
static pg_wchar static pg_wchar
pg_tolower(pg_wchar c) pg_wc_tolower(pg_wchar c)
{ {
if (c >= 0 && c <= UCHAR_MAX) if (c >= 0 && c <= UCHAR_MAX)
return tolower((unsigned char) c); return tolower((unsigned char) c);
@ -534,10 +534,10 @@ range(struct vars * v, /* context */
for (c = a; c <= b; c++) for (c = a; c <= b; c++)
{ {
addchr(cv, c); addchr(cv, c);
lc = pg_tolower((chr) c); lc = pg_wc_tolower((chr) c);
if (c != lc) if (c != lc)
addchr(cv, lc); addchr(cv, lc);
uc = pg_toupper((chr) c); uc = pg_wc_toupper((chr) c);
if (c != uc) if (c != uc)
addchr(cv, uc); addchr(cv, uc);
} }
@ -668,7 +668,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isprint((chr) i)) if (pg_wc_isprint((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -679,7 +679,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isalnum((chr) i)) if (pg_wc_isalnum((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -690,7 +690,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isalpha((chr) i)) if (pg_wc_isalpha((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -721,7 +721,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_ispunct((chr) i)) if (pg_wc_ispunct((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -741,7 +741,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isspace((chr) i)) if (pg_wc_isspace((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -752,7 +752,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_islower((chr) i)) if (pg_wc_islower((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -763,7 +763,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isupper((chr) i)) if (pg_wc_isupper((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -774,7 +774,7 @@ cclass(struct vars * v, /* context */
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isgraph((chr) i)) if (pg_wc_isgraph((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
} }
@ -800,8 +800,8 @@ allcases(struct vars * v, /* context */
chr lc, chr lc,
uc; uc;
lc = pg_tolower((chr) c); lc = pg_wc_tolower((chr) c);
uc = pg_toupper((chr) c); uc = pg_wc_toupper((chr) c);
cv = getcvec(v, 2, 0, 0); cv = getcvec(v, 2, 0, 0);
addchr(cv, lc); addchr(cv, lc);
@ -839,7 +839,7 @@ casecmp(const chr *x, const chr *y, /* strings to compare */
{ {
for (; len > 0; len--, x++, y++) for (; len > 0; len--, x++, y++)
{ {
if ((*x != *y) && (pg_tolower(*x) != pg_tolower(*y))) if ((*x != *y) && (pg_wc_tolower(*x) != pg_wc_tolower(*y)))
return 1; return 1;
} }
return 0; return 0;

View File

@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.40 2003/11/29 19:51:55 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.41 2004/05/07 00:24:57 tgl Exp $
* *
*/ */
@ -178,17 +178,17 @@ static struct cvec *getcvec(struct vars *, int, int, int);
static void freecvec(struct cvec *); static void freecvec(struct cvec *);
/* === regc_locale.c === */ /* === regc_locale.c === */
static int pg_isdigit(pg_wchar c); static int pg_wc_isdigit(pg_wchar c);
static int pg_isalpha(pg_wchar c); static int pg_wc_isalpha(pg_wchar c);
static int pg_isalnum(pg_wchar c); static int pg_wc_isalnum(pg_wchar c);
static int pg_isupper(pg_wchar c); static int pg_wc_isupper(pg_wchar c);
static int pg_islower(pg_wchar c); static int pg_wc_islower(pg_wchar c);
static int pg_isgraph(pg_wchar c); static int pg_wc_isgraph(pg_wchar c);
static int pg_isprint(pg_wchar c); static int pg_wc_isprint(pg_wchar c);
static int pg_ispunct(pg_wchar c); static int pg_wc_ispunct(pg_wchar c);
static int pg_isspace(pg_wchar c); static int pg_wc_isspace(pg_wchar c);
static pg_wchar pg_toupper(pg_wchar c); static pg_wchar pg_wc_toupper(pg_wchar c);
static pg_wchar pg_tolower(pg_wchar c); static pg_wchar pg_wc_tolower(pg_wchar c);
static int nmcces(struct vars *); static int nmcces(struct vars *);
static int nleaders(struct vars *); static int nleaders(struct vars *);
static struct cvec *allmcces(struct vars *, struct cvec *); static struct cvec *allmcces(struct vars *, struct cvec *);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.103 2004/05/02 13:38:27 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.104 2004/05/07 00:24:57 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -882,29 +882,29 @@ convert_priv_string(text *priv_type_text)
priv_type = DatumGetCString(DirectFunctionCall1(textout, priv_type = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(priv_type_text))); PointerGetDatum(priv_type_text)));
if (strcasecmp(priv_type, "SELECT") == 0) if (pg_strcasecmp(priv_type, "SELECT") == 0)
return ACL_SELECT; return ACL_SELECT;
if (strcasecmp(priv_type, "INSERT") == 0) if (pg_strcasecmp(priv_type, "INSERT") == 0)
return ACL_INSERT; return ACL_INSERT;
if (strcasecmp(priv_type, "UPDATE") == 0) if (pg_strcasecmp(priv_type, "UPDATE") == 0)
return ACL_UPDATE; return ACL_UPDATE;
if (strcasecmp(priv_type, "DELETE") == 0) if (pg_strcasecmp(priv_type, "DELETE") == 0)
return ACL_DELETE; return ACL_DELETE;
if (strcasecmp(priv_type, "RULE") == 0) if (pg_strcasecmp(priv_type, "RULE") == 0)
return ACL_RULE; return ACL_RULE;
if (strcasecmp(priv_type, "REFERENCES") == 0) if (pg_strcasecmp(priv_type, "REFERENCES") == 0)
return ACL_REFERENCES; return ACL_REFERENCES;
if (strcasecmp(priv_type, "TRIGGER") == 0) if (pg_strcasecmp(priv_type, "TRIGGER") == 0)
return ACL_TRIGGER; return ACL_TRIGGER;
if (strcasecmp(priv_type, "EXECUTE") == 0) if (pg_strcasecmp(priv_type, "EXECUTE") == 0)
return ACL_EXECUTE; return ACL_EXECUTE;
if (strcasecmp(priv_type, "USAGE") == 0) if (pg_strcasecmp(priv_type, "USAGE") == 0)
return ACL_USAGE; return ACL_USAGE;
if (strcasecmp(priv_type, "CREATE") == 0) if (pg_strcasecmp(priv_type, "CREATE") == 0)
return ACL_CREATE; return ACL_CREATE;
if (strcasecmp(priv_type, "TEMP") == 0) if (pg_strcasecmp(priv_type, "TEMP") == 0)
return ACL_CREATE_TEMP; return ACL_CREATE_TEMP;
if (strcasecmp(priv_type, "TEMPORARY") == 0) if (pg_strcasecmp(priv_type, "TEMPORARY") == 0)
return ACL_CREATE_TEMP; return ACL_CREATE_TEMP;
ereport(ERROR, ereport(ERROR,
@ -1097,39 +1097,39 @@ convert_table_priv_string(text *priv_type_text)
/* /*
* Return mode from priv_type string * Return mode from priv_type string
*/ */
if (strcasecmp(priv_type, "SELECT") == 0) if (pg_strcasecmp(priv_type, "SELECT") == 0)
return ACL_SELECT; return ACL_SELECT;
if (strcasecmp(priv_type, "SELECT WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "SELECT WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_SELECT); return ACL_GRANT_OPTION_FOR(ACL_SELECT);
if (strcasecmp(priv_type, "INSERT") == 0) if (pg_strcasecmp(priv_type, "INSERT") == 0)
return ACL_INSERT; return ACL_INSERT;
if (strcasecmp(priv_type, "INSERT WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "INSERT WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_INSERT); return ACL_GRANT_OPTION_FOR(ACL_INSERT);
if (strcasecmp(priv_type, "UPDATE") == 0) if (pg_strcasecmp(priv_type, "UPDATE") == 0)
return ACL_UPDATE; return ACL_UPDATE;
if (strcasecmp(priv_type, "UPDATE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "UPDATE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_UPDATE); return ACL_GRANT_OPTION_FOR(ACL_UPDATE);
if (strcasecmp(priv_type, "DELETE") == 0) if (pg_strcasecmp(priv_type, "DELETE") == 0)
return ACL_DELETE; return ACL_DELETE;
if (strcasecmp(priv_type, "DELETE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "DELETE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_DELETE); return ACL_GRANT_OPTION_FOR(ACL_DELETE);
if (strcasecmp(priv_type, "RULE") == 0) if (pg_strcasecmp(priv_type, "RULE") == 0)
return ACL_RULE; return ACL_RULE;
if (strcasecmp(priv_type, "RULE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "RULE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_RULE); return ACL_GRANT_OPTION_FOR(ACL_RULE);
if (strcasecmp(priv_type, "REFERENCES") == 0) if (pg_strcasecmp(priv_type, "REFERENCES") == 0)
return ACL_REFERENCES; return ACL_REFERENCES;
if (strcasecmp(priv_type, "REFERENCES WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "REFERENCES WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_REFERENCES); return ACL_GRANT_OPTION_FOR(ACL_REFERENCES);
if (strcasecmp(priv_type, "TRIGGER") == 0) if (pg_strcasecmp(priv_type, "TRIGGER") == 0)
return ACL_TRIGGER; return ACL_TRIGGER;
if (strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_TRIGGER); return ACL_GRANT_OPTION_FOR(ACL_TRIGGER);
ereport(ERROR, ereport(ERROR,
@ -1329,19 +1329,19 @@ convert_database_priv_string(text *priv_type_text)
/* /*
* Return mode from priv_type string * Return mode from priv_type string
*/ */
if (strcasecmp(priv_type, "CREATE") == 0) if (pg_strcasecmp(priv_type, "CREATE") == 0)
return ACL_CREATE; return ACL_CREATE;
if (strcasecmp(priv_type, "CREATE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "CREATE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_CREATE); return ACL_GRANT_OPTION_FOR(ACL_CREATE);
if (strcasecmp(priv_type, "TEMPORARY") == 0) if (pg_strcasecmp(priv_type, "TEMPORARY") == 0)
return ACL_CREATE_TEMP; return ACL_CREATE_TEMP;
if (strcasecmp(priv_type, "TEMPORARY WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "TEMPORARY WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP); return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP);
if (strcasecmp(priv_type, "TEMP") == 0) if (pg_strcasecmp(priv_type, "TEMP") == 0)
return ACL_CREATE_TEMP; return ACL_CREATE_TEMP;
if (strcasecmp(priv_type, "TEMP WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "TEMP WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP); return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP);
ereport(ERROR, ereport(ERROR,
@ -1543,9 +1543,9 @@ convert_function_priv_string(text *priv_type_text)
/* /*
* Return mode from priv_type string * Return mode from priv_type string
*/ */
if (strcasecmp(priv_type, "EXECUTE") == 0) if (pg_strcasecmp(priv_type, "EXECUTE") == 0)
return ACL_EXECUTE; return ACL_EXECUTE;
if (strcasecmp(priv_type, "EXECUTE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "EXECUTE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_EXECUTE); return ACL_GRANT_OPTION_FOR(ACL_EXECUTE);
ereport(ERROR, ereport(ERROR,
@ -1747,9 +1747,9 @@ convert_language_priv_string(text *priv_type_text)
/* /*
* Return mode from priv_type string * Return mode from priv_type string
*/ */
if (strcasecmp(priv_type, "USAGE") == 0) if (pg_strcasecmp(priv_type, "USAGE") == 0)
return ACL_USAGE; return ACL_USAGE;
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_USAGE); return ACL_GRANT_OPTION_FOR(ACL_USAGE);
ereport(ERROR, ereport(ERROR,
@ -1951,14 +1951,14 @@ convert_schema_priv_string(text *priv_type_text)
/* /*
* Return mode from priv_type string * Return mode from priv_type string
*/ */
if (strcasecmp(priv_type, "CREATE") == 0) if (pg_strcasecmp(priv_type, "CREATE") == 0)
return ACL_CREATE; return ACL_CREATE;
if (strcasecmp(priv_type, "CREATE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "CREATE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_CREATE); return ACL_GRANT_OPTION_FOR(ACL_CREATE);
if (strcasecmp(priv_type, "USAGE") == 0) if (pg_strcasecmp(priv_type, "USAGE") == 0)
return ACL_USAGE; return ACL_USAGE;
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0) if (pg_strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_USAGE); return ACL_GRANT_OPTION_FOR(ACL_USAGE);
ereport(ERROR, ereport(ERROR,

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.31 2003/11/29 19:51:58 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.32 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -39,35 +39,35 @@ boolin(PG_FUNCTION_ARGS)
{ {
case 't': case 't':
case 'T': case 'T':
if (strncasecmp(b, "true", strlen(b)) == 0) if (pg_strncasecmp(b, "true", strlen(b)) == 0)
PG_RETURN_BOOL(true); PG_RETURN_BOOL(true);
break; break;
case 'f': case 'f':
case 'F': case 'F':
if (strncasecmp(b, "false", strlen(b)) == 0) if (pg_strncasecmp(b, "false", strlen(b)) == 0)
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
break; break;
case 'y': case 'y':
case 'Y': case 'Y':
if (strncasecmp(b, "yes", strlen(b)) == 0) if (pg_strncasecmp(b, "yes", strlen(b)) == 0)
PG_RETURN_BOOL(true); PG_RETURN_BOOL(true);
break; break;
case '1': case '1':
if (strncasecmp(b, "1", strlen(b)) == 0) if (pg_strncasecmp(b, "1", strlen(b)) == 0)
PG_RETURN_BOOL(true); PG_RETURN_BOOL(true);
break; break;
case 'n': case 'n':
case 'N': case 'N':
if (strncasecmp(b, "no", strlen(b)) == 0) if (pg_strncasecmp(b, "no", strlen(b)) == 0)
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
break; break;
case '0': case '0':
if (strncasecmp(b, "0", strlen(b)) == 0) if (pg_strncasecmp(b, "0", strlen(b)) == 0)
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
break; break;

View File

@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by * workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.62 2003/11/29 19:51:58 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.63 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
@ -745,7 +745,7 @@ cash_words(PG_FUNCTION_ARGS)
strcat(buf, m0 == 1 ? " cent" : " cents"); strcat(buf, m0 == 1 ? " cent" : " cents");
/* capitalize output */ /* capitalize output */
buf[0] = toupper((unsigned char) buf[0]); buf[0] = pg_toupper((unsigned char) buf[0]);
/* make a text type for output */ /* make a text type for output */
result = (text *) palloc(strlen(buf) + VARHDRSZ); result = (text *) palloc(strlen(buf) + VARHDRSZ);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.95 2004/02/14 20:16:17 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.96 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -23,6 +23,7 @@
#include "access/hash.h" #include "access/hash.h"
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/scansup.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/date.h" #include "utils/date.h"
#include "utils/nabstime.h" #include "utils/nabstime.h"
@ -1627,23 +1628,11 @@ time_part(PG_FUNCTION_ARGS)
float8 result; float8 result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) lowunits = downcase_truncate_identifier(VARDATA(units),
ereport(ERROR, VARSIZE(units) - VARHDRSZ,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), false);
errmsg("\"time\" units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val); type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD) if (type == UNKNOWN_FIELD)
@ -2390,23 +2379,11 @@ timetz_part(PG_FUNCTION_ARGS)
float8 result; float8 result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) lowunits = downcase_truncate_identifier(VARDATA(units),
ereport(ERROR, VARSIZE(units) - VARHDRSZ,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), false);
errmsg("\"time with time zone\" units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val); type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD) if (type == UNKNOWN_FIELD)
@ -2523,23 +2500,11 @@ timetz_zone(PG_FUNCTION_ARGS)
int tz; int tz;
int type, int type,
val; val;
int i; char *lowzone;
char *up,
*lp,
lowzone[MAXDATELEN + 1];
if (VARSIZE(zone) - VARHDRSZ > MAXDATELEN) lowzone = downcase_truncate_identifier(VARDATA(zone),
ereport(ERROR, VARSIZE(zone) - VARHDRSZ,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), false);
errmsg("time zone \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(zone))))));
up = VARDATA(zone);
lp = lowzone;
for (i = 0; i < (VARSIZE(zone) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeSpecial(0, lowzone, &val); type = DecodeSpecial(0, lowzone, &val);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.126 2004/03/30 15:53:18 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.127 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -794,7 +794,7 @@ ParseDateTime(const char *timestr, char *lowstr,
{ {
ftype[nf] = DTK_DATE; ftype[nf] = DTK_DATE;
while (isalnum((unsigned char) *cp) || (*cp == delim)) while (isalnum((unsigned char) *cp) || (*cp == delim))
*lp++ = tolower((unsigned char) *cp++); *lp++ = pg_tolower((unsigned char) *cp++);
} }
} }
@ -822,9 +822,9 @@ ParseDateTime(const char *timestr, char *lowstr,
else if (isalpha((unsigned char) *cp)) else if (isalpha((unsigned char) *cp))
{ {
ftype[nf] = DTK_STRING; ftype[nf] = DTK_STRING;
*lp++ = tolower((unsigned char) *cp++); *lp++ = pg_tolower((unsigned char) *cp++);
while (isalpha((unsigned char) *cp)) while (isalpha((unsigned char) *cp))
*lp++ = tolower((unsigned char) *cp++); *lp++ = pg_tolower((unsigned char) *cp++);
/* /*
* Full date string with leading text month? Could also be a * Full date string with leading text month? Could also be a
@ -860,9 +860,9 @@ ParseDateTime(const char *timestr, char *lowstr,
else if (isalpha((unsigned char) *cp)) else if (isalpha((unsigned char) *cp))
{ {
ftype[nf] = DTK_SPECIAL; ftype[nf] = DTK_SPECIAL;
*lp++ = tolower((unsigned char) *cp++); *lp++ = pg_tolower((unsigned char) *cp++);
while (isalpha((unsigned char) *cp)) while (isalpha((unsigned char) *cp))
*lp++ = tolower((unsigned char) *cp++); *lp++ = pg_tolower((unsigned char) *cp++);
} }
/* otherwise something wrong... */ /* otherwise something wrong... */
else else

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.10 2003/11/29 19:51:58 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.11 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -549,7 +549,7 @@ pg_find_encoding(const char *name)
int i; int i;
for (i = 0; enclist[i].name; i++) for (i = 0; enclist[i].name; i++)
if (strcasecmp(enclist[i].name, name) == 0) if (pg_strcasecmp(enclist[i].name, name) == 0)
return &enclist[i].enc; return &enclist[i].enc;
return NULL; return NULL;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.103 2004/04/01 23:52:18 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.104 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -291,17 +291,17 @@ float4in(PG_FUNCTION_ARGS)
* set ERANGE anyway...) Therefore, we check for these inputs * set ERANGE anyway...) Therefore, we check for these inputs
* ourselves. * ourselves.
*/ */
if (strncasecmp(num, "NaN", 3) == 0) if (pg_strncasecmp(num, "NaN", 3) == 0)
{ {
val = get_float4_nan(); val = get_float4_nan();
endptr = num + 3; endptr = num + 3;
} }
else if (strncasecmp(num, "Infinity", 8) == 0) else if (pg_strncasecmp(num, "Infinity", 8) == 0)
{ {
val = get_float4_infinity(); val = get_float4_infinity();
endptr = num + 8; endptr = num + 8;
} }
else if (strncasecmp(num, "-Infinity", 9) == 0) else if (pg_strncasecmp(num, "-Infinity", 9) == 0)
{ {
val = - get_float4_infinity(); val = - get_float4_infinity();
endptr = num + 9; endptr = num + 9;
@ -456,17 +456,17 @@ float8in(PG_FUNCTION_ARGS)
* set ERANGE anyway...) Therefore, we check for these inputs * set ERANGE anyway...) Therefore, we check for these inputs
* ourselves. * ourselves.
*/ */
if (strncasecmp(num, "NaN", 3) == 0) if (pg_strncasecmp(num, "NaN", 3) == 0)
{ {
val = get_float8_nan(); val = get_float8_nan();
endptr = num + 3; endptr = num + 3;
} }
else if (strncasecmp(num, "Infinity", 8) == 0) else if (pg_strncasecmp(num, "Infinity", 8) == 0)
{ {
val = get_float8_infinity(); val = get_float8_infinity();
endptr = num + 8; endptr = num + 8;
} }
else if (strncasecmp(num, "-Infinity", 9) == 0) else if (pg_strncasecmp(num, "-Infinity", 9) == 0)
{ {
val = - get_float8_infinity(); val = - get_float8_infinity();
endptr = num + 9; endptr = num + 9;

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.73 2004/03/30 15:53:18 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.74 2004/05/07 00:24:58 tgl Exp $
* *
* *
* Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group
@ -1477,7 +1477,7 @@ str_toupper(char *buff)
while (*p_buff) while (*p_buff)
{ {
*p_buff = toupper((unsigned char) *p_buff); *p_buff = pg_toupper((unsigned char) *p_buff);
++p_buff; ++p_buff;
} }
return buff; return buff;
@ -1497,7 +1497,7 @@ str_tolower(char *buff)
while (*p_buff) while (*p_buff)
{ {
*p_buff = tolower((unsigned char) *p_buff); *p_buff = pg_tolower((unsigned char) *p_buff);
++p_buff; ++p_buff;
} }
return buff; return buff;
@ -1523,9 +1523,9 @@ seq_search(char *name, char **array, int type, int max, int *len)
/* set first char */ /* set first char */
if (type == ONE_UPPER || type == ALL_UPPER) if (type == ONE_UPPER || type == ALL_UPPER)
*name = toupper((unsigned char) *name); *name = pg_toupper((unsigned char) *name);
else if (type == ALL_LOWER) else if (type == ALL_LOWER)
*name = tolower((unsigned char) *name); *name = pg_tolower((unsigned char) *name);
for (last = 0, a = array; *a != NULL; a++) for (last = 0, a = array; *a != NULL; a++)
{ {
@ -1559,9 +1559,9 @@ seq_search(char *name, char **array, int type, int max, int *len)
if (i > last) if (i > last)
{ {
if (type == ONE_UPPER || type == ALL_LOWER) if (type == ONE_UPPER || type == ALL_LOWER)
*n = tolower((unsigned char) *n); *n = pg_tolower((unsigned char) *n);
else if (type == ALL_UPPER) else if (type == ALL_UPPER)
*n = toupper((unsigned char) *n); *n = pg_toupper((unsigned char) *n);
last = i; last = i;
} }
@ -2192,7 +2192,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_month: case DCH_month:
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]); sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]);
*inout = tolower((unsigned char) *inout); *inout = pg_tolower((unsigned char) *inout);
if (S_FM(suf)) if (S_FM(suf))
return strlen(p_inout) - 1; return strlen(p_inout) - 1;
else else
@ -2209,7 +2209,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_mon: case DCH_mon:
strcpy(inout, months[tm->tm_mon - 1]); strcpy(inout, months[tm->tm_mon - 1]);
*inout = tolower((unsigned char) *inout); *inout = pg_tolower((unsigned char) *inout);
return 2; return 2;
case DCH_MM: case DCH_MM:
@ -2255,7 +2255,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_day: case DCH_day:
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]); sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]);
*inout = tolower((unsigned char) *inout); *inout = pg_tolower((unsigned char) *inout);
if (S_FM(suf)) if (S_FM(suf))
return strlen(p_inout) - 1; return strlen(p_inout) - 1;
else else
@ -2272,7 +2272,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_dy: case DCH_dy:
strcpy(inout, days[tm->tm_wday]); strcpy(inout, days[tm->tm_wday]);
*inout = tolower((unsigned char) *inout); *inout = pg_tolower((unsigned char) *inout);
return 2; return 2;
case DCH_DDD: case DCH_DDD:

View File

@ -14,7 +14,7 @@
* Copyright (c) 1998-2003, PostgreSQL Global Development Group * Copyright (c) 1998-2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.72 2004/03/15 03:29:22 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.73 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -315,7 +315,7 @@ numeric_in(PG_FUNCTION_ARGS)
/* /*
* Check for NaN * Check for NaN
*/ */
if (strcasecmp(str, "NaN") == 0) if (pg_strcasecmp(str, "NaN") == 0)
PG_RETURN_NUMERIC(make_result(&const_nan)); PG_RETURN_NUMERIC(make_result(&const_nan));
/* /*

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.52 2004/02/03 17:52:55 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.53 2004/05/07 00:24:58 tgl Exp $
* *
* Alistair Crooks added the code for the regex caching * Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance * agc - cached the regular expressions used - there's a good chance
@ -233,17 +233,17 @@ const char *
assign_regex_flavor(const char *value, assign_regex_flavor(const char *value,
bool doit, GucSource source) bool doit, GucSource source)
{ {
if (strcasecmp(value, "advanced") == 0) if (pg_strcasecmp(value, "advanced") == 0)
{ {
if (doit) if (doit)
regex_flavor = REG_ADVANCED; regex_flavor = REG_ADVANCED;
} }
else if (strcasecmp(value, "extended") == 0) else if (pg_strcasecmp(value, "extended") == 0)
{ {
if (doit) if (doit)
regex_flavor = REG_EXTENDED; regex_flavor = REG_EXTENDED;
} }
else if (strcasecmp(value, "basic") == 0) else if (pg_strcasecmp(value, "basic") == 0)
{ {
if (doit) if (doit)
regex_flavor = REG_BASIC; regex_flavor = REG_BASIC;

View File

@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.86 2004/01/31 05:09:40 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.87 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1259,7 +1259,7 @@ parseNameAndArgTypes(const char *string, const char *caller,
*ptr2 = '\0'; *ptr2 = '\0';
} }
if (allowNone && strcasecmp(typename, "none") == 0) if (allowNone && pg_strcasecmp(typename, "none") == 0)
{ {
/* Special case for NONE */ /* Special case for NONE */
typeid = InvalidOid; typeid = InvalidOid;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.42 2003/11/29 19:51:59 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.43 2004/05/07 00:24:58 tgl Exp $
* *
* NOTES * NOTES
* input routine largely stolen from boxin(). * input routine largely stolen from boxin().
@ -218,7 +218,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
for (i = 0; i < natts; i++) for (i = 0; i < natts; i++)
{ {
if (strcasecmp(NameStr(att->attrs[i]->attname), "ctid") == 0) if (strcmp(NameStr(att->attrs[i]->attname), "ctid") == 0)
{ {
if (att->attrs[i]->atttypid != TIDOID) if (att->attrs[i]->atttypid != TIDOID)
elog(ERROR, "ctid isn't of type TID"); elog(ERROR, "ctid isn't of type TID");

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.104 2004/04/10 18:02:59 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.105 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -26,6 +26,7 @@
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/scansup.h"
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h" #include "utils/builtins.h"
@ -2699,32 +2700,20 @@ timestamp_trunc(PG_FUNCTION_ARGS)
Timestamp result; Timestamp result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
fsec_t fsec; fsec_t fsec;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timestamp units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val);
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
PG_RETURN_TIMESTAMP(timestamp); PG_RETURN_TIMESTAMP(timestamp);
lowunits = downcase_truncate_identifier(VARDATA(units),
VARSIZE(units) - VARHDRSZ,
false);
type = DecodeUnits(0, lowunits, &val);
if (type == UNITS) if (type == UNITS)
{ {
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0) if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
@ -2814,32 +2803,21 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
int tz; int tz;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
fsec_t fsec; fsec_t fsec;
char *tzn; char *tzn;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timestamp with time zone units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val);
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
PG_RETURN_TIMESTAMPTZ(timestamp); PG_RETURN_TIMESTAMPTZ(timestamp);
lowunits = downcase_truncate_identifier(VARDATA(units),
VARSIZE(units) - VARHDRSZ,
false);
type = DecodeUnits(0, lowunits, &val);
if (type == UNITS) if (type == UNITS)
{ {
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0) if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
@ -2929,27 +2907,16 @@ interval_trunc(PG_FUNCTION_ARGS)
Interval *result; Interval *result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
fsec_t fsec; fsec_t fsec;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
result = (Interval *) palloc(sizeof(Interval)); result = (Interval *) palloc(sizeof(Interval));
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) lowunits = downcase_truncate_identifier(VARDATA(units),
ereport(ERROR, VARSIZE(units) - VARHDRSZ,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), false);
errmsg("interval units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val); type = DecodeUnits(0, lowunits, &val);
@ -3173,36 +3140,25 @@ timestamp_part(PG_FUNCTION_ARGS)
float8 result; float8 result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
fsec_t fsec; fsec_t fsec;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timestamp units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD)
type = DecodeSpecial(0, lowunits, &val);
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
{ {
result = 0; result = 0;
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
} }
lowunits = downcase_truncate_identifier(VARDATA(units),
VARSIZE(units) - VARHDRSZ,
false);
type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD)
type = DecodeSpecial(0, lowunits, &val);
if (type == UNITS) if (type == UNITS)
{ {
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0) if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
@ -3395,38 +3351,27 @@ timestamptz_part(PG_FUNCTION_ARGS)
int tz; int tz;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
double dummy; double dummy;
fsec_t fsec; fsec_t fsec;
char *tzn; char *tzn;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timestamp with time zone units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD)
type = DecodeSpecial(0, lowunits, &val);
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
{ {
result = 0; result = 0;
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
} }
lowunits = downcase_truncate_identifier(VARDATA(units),
VARSIZE(units) - VARHDRSZ,
false);
type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD)
type = DecodeSpecial(0, lowunits, &val);
if (type == UNITS) if (type == UNITS)
{ {
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0) if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
@ -3597,25 +3542,14 @@ interval_part(PG_FUNCTION_ARGS)
float8 result; float8 result;
int type, int type,
val; val;
int i; char *lowunits;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
fsec_t fsec; fsec_t fsec;
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) lowunits = downcase_truncate_identifier(VARDATA(units),
ereport(ERROR, VARSIZE(units) - VARHDRSZ,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), false);
errmsg("interval units \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeUnits(0, lowunits, &val); type = DecodeUnits(0, lowunits, &val);
if (type == UNKNOWN_FIELD) if (type == UNKNOWN_FIELD)
@ -3744,26 +3678,14 @@ timestamp_zone(PG_FUNCTION_ARGS)
int tz; int tz;
int type, int type,
val; val;
int i; char *lowzone;
char *up,
*lp,
lowzone[MAXDATELEN + 1];
if (VARSIZE(zone) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("time zone \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(zone))))));
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
PG_RETURN_TIMESTAMPTZ(timestamp); PG_RETURN_TIMESTAMPTZ(timestamp);
up = VARDATA(zone); lowzone = downcase_truncate_identifier(VARDATA(zone),
lp = lowzone; VARSIZE(zone) - VARHDRSZ,
for (i = 0; i < (VARSIZE(zone) - VARHDRSZ); i++) false);
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeSpecial(0, lowzone, &val); type = DecodeSpecial(0, lowzone, &val);
@ -3903,28 +3825,17 @@ timestamptz_zone(PG_FUNCTION_ARGS)
int tz; int tz;
int type, int type,
val; val;
int i; char *lowzone;
char *up,
*lp,
lowzone[MAXDATELEN + 1];
if (VARSIZE(zone) - VARHDRSZ > MAXDATELEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("time zone \"%s\" not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(zone))))));
up = VARDATA(zone);
lp = lowzone;
for (i = 0; i < (VARSIZE(zone) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeSpecial(0, lowzone, &val);
if (TIMESTAMP_NOT_FINITE(timestamp)) if (TIMESTAMP_NOT_FINITE(timestamp))
PG_RETURN_NULL(); PG_RETURN_NULL();
lowzone = downcase_truncate_identifier(VARDATA(zone),
VARSIZE(zone) - VARHDRSZ,
false);
type = DecodeSpecial(0, lowzone, &val);
if ((type == TZ) || (type == DTZ)) if ((type == TZ) || (type == DTZ))
{ {
tz = val * 60; tz = val * 60;

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.135 2004/04/22 03:51:09 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.136 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1010,21 +1010,21 @@ write_syslog(int level, const char *line)
if (!openlog_done) if (!openlog_done)
{ {
if (strcasecmp(Syslog_facility, "LOCAL0") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL0") == 0)
syslog_fac = LOG_LOCAL0; syslog_fac = LOG_LOCAL0;
if (strcasecmp(Syslog_facility, "LOCAL1") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL1") == 0)
syslog_fac = LOG_LOCAL1; syslog_fac = LOG_LOCAL1;
if (strcasecmp(Syslog_facility, "LOCAL2") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL2") == 0)
syslog_fac = LOG_LOCAL2; syslog_fac = LOG_LOCAL2;
if (strcasecmp(Syslog_facility, "LOCAL3") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL3") == 0)
syslog_fac = LOG_LOCAL3; syslog_fac = LOG_LOCAL3;
if (strcasecmp(Syslog_facility, "LOCAL4") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL4") == 0)
syslog_fac = LOG_LOCAL4; syslog_fac = LOG_LOCAL4;
if (strcasecmp(Syslog_facility, "LOCAL5") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL5") == 0)
syslog_fac = LOG_LOCAL5; syslog_fac = LOG_LOCAL5;
if (strcasecmp(Syslog_facility, "LOCAL6") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL6") == 0)
syslog_fac = LOG_LOCAL6; syslog_fac = LOG_LOCAL6;
if (strcasecmp(Syslog_facility, "LOCAL7") == 0) if (pg_strcasecmp(Syslog_facility, "LOCAL7") == 0)
syslog_fac = LOG_LOCAL7; syslog_fac = LOG_LOCAL7;
openlog(Syslog_ident, LOG_PID | LOG_NDELAY, syslog_fac); openlog(Syslog_ident, LOG_PID | LOG_NDELAY, syslog_fac);
openlog_done = true; openlog_done = true;

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.201 2004/04/19 21:22:14 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.202 2004/05/07 00:24:58 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -2443,45 +2443,45 @@ parse_bool(const char *value, bool *result)
{ {
size_t len = strlen(value); size_t len = strlen(value);
if (strncasecmp(value, "true", len) == 0) if (pg_strncasecmp(value, "true", len) == 0)
{ {
if (result) if (result)
*result = true; *result = true;
} }
else if (strncasecmp(value, "false", len) == 0) else if (pg_strncasecmp(value, "false", len) == 0)
{ {
if (result) if (result)
*result = false; *result = false;
} }
else if (strncasecmp(value, "yes", len) == 0) else if (pg_strncasecmp(value, "yes", len) == 0)
{ {
if (result) if (result)
*result = true; *result = true;
} }
else if (strncasecmp(value, "no", len) == 0) else if (pg_strncasecmp(value, "no", len) == 0)
{ {
if (result) if (result)
*result = false; *result = false;
} }
else if (strcasecmp(value, "on") == 0) else if (pg_strcasecmp(value, "on") == 0)
{ {
if (result) if (result)
*result = true; *result = true;
} }
else if (strcasecmp(value, "off") == 0) else if (pg_strcasecmp(value, "off") == 0)
{ {
if (result) if (result)
*result = false; *result = false;
} }
else if (strcasecmp(value, "1") == 0) else if (pg_strcasecmp(value, "1") == 0)
{ {
if (result) if (result)
*result = true; *result = true;
} }
else if (strcasecmp(value, "0") == 0) else if (pg_strcasecmp(value, "0") == 0)
{ {
if (result) if (result)
*result = false; *result = false;
@ -3463,7 +3463,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
void void
GetPGVariable(const char *name, DestReceiver *dest) GetPGVariable(const char *name, DestReceiver *dest)
{ {
if (strcasecmp(name, "all") == 0) if (pg_strcasecmp(name, "all") == 0)
ShowAllGUCConfig(dest); ShowAllGUCConfig(dest);
else else
ShowGUCConfigOption(name, dest); ShowGUCConfigOption(name, dest);
@ -3474,7 +3474,7 @@ GetPGVariableResultDesc(const char *name)
{ {
TupleDesc tupdesc; TupleDesc tupdesc;
if (strcasecmp(name, "all") == 0) if (pg_strcasecmp(name, "all") == 0)
{ {
/* need a tuple descriptor representing two TEXT columns */ /* need a tuple descriptor representing two TEXT columns */
tupdesc = CreateTemplateTupleDesc(2, false); tupdesc = CreateTemplateTupleDesc(2, false);
@ -3504,7 +3504,7 @@ GetPGVariableResultDesc(const char *name)
void void
ResetPGVariable(const char *name) ResetPGVariable(const char *name)
{ {
if (strcasecmp(name, "all") == 0) if (pg_strcasecmp(name, "all") == 0)
ResetAllOptions(); ResetAllOptions();
else else
set_config_option(name, set_config_option(name,
@ -4455,14 +4455,14 @@ assign_log_destination(const char *value, bool doit, GucSource source)
{ {
char *tok = (char *) lfirst(l); char *tok = (char *) lfirst(l);
if (strcasecmp(tok,"stderr") == 0) if (pg_strcasecmp(tok,"stderr") == 0)
newlogdest |= LOG_DESTINATION_STDERR; newlogdest |= LOG_DESTINATION_STDERR;
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
else if (strcasecmp(tok,"syslog") == 0) else if (pg_strcasecmp(tok,"syslog") == 0)
newlogdest |= LOG_DESTINATION_SYSLOG; newlogdest |= LOG_DESTINATION_SYSLOG;
#endif #endif
#ifdef WIN32 #ifdef WIN32
else if (strcasecmp(tok,"eventlog") == 0) else if (pg_strcasecmp(tok,"eventlog") == 0)
newlogdest |= LOG_DESTINATION_EVENTLOG; newlogdest |= LOG_DESTINATION_EVENTLOG;
#endif #endif
else { else {
@ -4494,21 +4494,21 @@ assign_log_destination(const char *value, bool doit, GucSource source)
static const char * static const char *
assign_facility(const char *facility, bool doit, GucSource source) assign_facility(const char *facility, bool doit, GucSource source)
{ {
if (strcasecmp(facility, "LOCAL0") == 0) if (pg_strcasecmp(facility, "LOCAL0") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL1") == 0) if (pg_strcasecmp(facility, "LOCAL1") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL2") == 0) if (pg_strcasecmp(facility, "LOCAL2") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL3") == 0) if (pg_strcasecmp(facility, "LOCAL3") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL4") == 0) if (pg_strcasecmp(facility, "LOCAL4") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL5") == 0) if (pg_strcasecmp(facility, "LOCAL5") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL6") == 0) if (pg_strcasecmp(facility, "LOCAL6") == 0)
return facility; return facility;
if (strcasecmp(facility, "LOCAL7") == 0) if (pg_strcasecmp(facility, "LOCAL7") == 0)
return facility; return facility;
return NULL; return NULL;
} }
@ -4518,22 +4518,22 @@ assign_facility(const char *facility, bool doit, GucSource source)
static const char * static const char *
assign_defaultxactisolevel(const char *newval, bool doit, GucSource source) assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "serializable") == 0) if (pg_strcasecmp(newval, "serializable") == 0)
{ {
if (doit) if (doit)
DefaultXactIsoLevel = XACT_SERIALIZABLE; DefaultXactIsoLevel = XACT_SERIALIZABLE;
} }
else if (strcasecmp(newval, "repeatable read") == 0) else if (pg_strcasecmp(newval, "repeatable read") == 0)
{ {
if (doit) if (doit)
DefaultXactIsoLevel = XACT_REPEATABLE_READ; DefaultXactIsoLevel = XACT_REPEATABLE_READ;
} }
else if (strcasecmp(newval, "read committed") == 0) else if (pg_strcasecmp(newval, "read committed") == 0)
{ {
if (doit) if (doit)
DefaultXactIsoLevel = XACT_READ_COMMITTED; DefaultXactIsoLevel = XACT_READ_COMMITTED;
} }
else if (strcasecmp(newval, "read uncommitted") == 0) else if (pg_strcasecmp(newval, "read uncommitted") == 0)
{ {
if (doit) if (doit)
DefaultXactIsoLevel = XACT_READ_UNCOMMITTED; DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
@ -4566,68 +4566,68 @@ assign_min_error_statement(const char *newval, bool doit, GucSource source)
static const char * static const char *
assign_msglvl(int *var, const char *newval, bool doit, GucSource source) assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "debug") == 0) if (pg_strcasecmp(newval, "debug") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG2; (*var) = DEBUG2;
} }
else if (strcasecmp(newval, "debug5") == 0) else if (pg_strcasecmp(newval, "debug5") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG5; (*var) = DEBUG5;
} }
else if (strcasecmp(newval, "debug4") == 0) else if (pg_strcasecmp(newval, "debug4") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG4; (*var) = DEBUG4;
} }
else if (strcasecmp(newval, "debug3") == 0) else if (pg_strcasecmp(newval, "debug3") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG3; (*var) = DEBUG3;
} }
else if (strcasecmp(newval, "debug2") == 0) else if (pg_strcasecmp(newval, "debug2") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG2; (*var) = DEBUG2;
} }
else if (strcasecmp(newval, "debug1") == 0) else if (pg_strcasecmp(newval, "debug1") == 0)
{ {
if (doit) if (doit)
(*var) = DEBUG1; (*var) = DEBUG1;
} }
else if (strcasecmp(newval, "log") == 0) else if (pg_strcasecmp(newval, "log") == 0)
{ {
if (doit) if (doit)
(*var) = LOG; (*var) = LOG;
} }
else if (strcasecmp(newval, "info") == 0) else if (pg_strcasecmp(newval, "info") == 0)
{ {
if (doit) if (doit)
(*var) = INFO; (*var) = INFO;
} }
else if (strcasecmp(newval, "notice") == 0) else if (pg_strcasecmp(newval, "notice") == 0)
{ {
if (doit) if (doit)
(*var) = NOTICE; (*var) = NOTICE;
} }
else if (strcasecmp(newval, "warning") == 0) else if (pg_strcasecmp(newval, "warning") == 0)
{ {
if (doit) if (doit)
(*var) = WARNING; (*var) = WARNING;
} }
else if (strcasecmp(newval, "error") == 0) else if (pg_strcasecmp(newval, "error") == 0)
{ {
if (doit) if (doit)
(*var) = ERROR; (*var) = ERROR;
} }
/* We allow FATAL/PANIC for client-side messages too. */ /* We allow FATAL/PANIC for client-side messages too. */
else if (strcasecmp(newval, "fatal") == 0) else if (pg_strcasecmp(newval, "fatal") == 0)
{ {
if (doit) if (doit)
(*var) = FATAL; (*var) = FATAL;
} }
else if (strcasecmp(newval, "panic") == 0) else if (pg_strcasecmp(newval, "panic") == 0)
{ {
if (doit) if (doit)
(*var) = PANIC; (*var) = PANIC;
@ -4640,17 +4640,17 @@ assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
static const char * static const char *
assign_log_error_verbosity(const char *newval, bool doit, GucSource source) assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "terse") == 0) if (pg_strcasecmp(newval, "terse") == 0)
{ {
if (doit) if (doit)
Log_error_verbosity = PGERROR_TERSE; Log_error_verbosity = PGERROR_TERSE;
} }
else if (strcasecmp(newval, "default") == 0) else if (pg_strcasecmp(newval, "default") == 0)
{ {
if (doit) if (doit)
Log_error_verbosity = PGERROR_DEFAULT; Log_error_verbosity = PGERROR_DEFAULT;
} }
else if (strcasecmp(newval, "verbose") == 0) else if (pg_strcasecmp(newval, "verbose") == 0)
{ {
if (doit) if (doit)
Log_error_verbosity = PGERROR_VERBOSE; Log_error_verbosity = PGERROR_VERBOSE;
@ -4669,22 +4669,22 @@ assign_log_statement(const char *newval, bool doit, GucSource source)
static const char * static const char *
assign_log_stmtlvl(int *var, const char *newval, bool doit, GucSource source) assign_log_stmtlvl(int *var, const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "none") == 0) if (pg_strcasecmp(newval, "none") == 0)
{ {
if (doit) if (doit)
(*var) = LOGSTMT_NONE; (*var) = LOGSTMT_NONE;
} }
else if (strcasecmp(newval, "mod") == 0) else if (pg_strcasecmp(newval, "mod") == 0)
{ {
if (doit) if (doit)
(*var) = LOGSTMT_MOD; (*var) = LOGSTMT_MOD;
} }
else if (strcasecmp(newval, "ddl") == 0) else if (pg_strcasecmp(newval, "ddl") == 0)
{ {
if (doit) if (doit)
(*var) = LOGSTMT_DDL; (*var) = LOGSTMT_DDL;
} }
else if (strcasecmp(newval, "all") == 0) else if (pg_strcasecmp(newval, "all") == 0)
{ {
if (doit) if (doit)
(*var) = LOGSTMT_ALL; (*var) = LOGSTMT_ALL;

View File

@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.42 2004/03/03 21:28:54 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.43 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -627,7 +627,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* Get a copy of the COPY statement and clean it up */ /* Get a copy of the COPY statement and clean it up */
tmpCopy = strdup(te->copyStmt); tmpCopy = strdup(te->copyStmt);
for (i = 0; i < strlen(tmpCopy); i++) for (i = 0; i < strlen(tmpCopy); i++)
tmpCopy[i] = tolower((unsigned char) tmpCopy[i]); tmpCopy[i] = pg_tolower((unsigned char) tmpCopy[i]);
/* /*
* This is very nasty; we don't know if the archive used WITH * This is very nasty; we don't know if the archive used WITH

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.115 2004/03/27 18:01:40 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.116 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
@ -263,7 +263,7 @@ exec_command(const char *cmd,
} }
/* \copy */ /* \copy */
else if (strcasecmp(cmd, "copy") == 0) else if (pg_strcasecmp(cmd, "copy") == 0)
{ {
char *opt = psql_scan_slash_option(scan_state, char *opt = psql_scan_slash_option(scan_state,
OT_WHOLE_LINE, NULL, false); OT_WHOLE_LINE, NULL, false);
@ -1321,13 +1321,13 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
{ {
if (!value) if (!value)
; ;
else if (strncasecmp("unaligned", value, vallen) == 0) else if (pg_strncasecmp("unaligned", value, vallen) == 0)
popt->topt.format = PRINT_UNALIGNED; popt->topt.format = PRINT_UNALIGNED;
else if (strncasecmp("aligned", value, vallen) == 0) else if (pg_strncasecmp("aligned", value, vallen) == 0)
popt->topt.format = PRINT_ALIGNED; popt->topt.format = PRINT_ALIGNED;
else if (strncasecmp("html", value, vallen) == 0) else if (pg_strncasecmp("html", value, vallen) == 0)
popt->topt.format = PRINT_HTML; popt->topt.format = PRINT_HTML;
else if (strncasecmp("latex", value, vallen) == 0) else if (pg_strncasecmp("latex", value, vallen) == 0)
popt->topt.format = PRINT_LATEX; popt->topt.format = PRINT_LATEX;
else else
{ {
@ -1452,7 +1452,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
/* toggle use of pager */ /* toggle use of pager */
else if (strcmp(param, "pager") == 0) else if (strcmp(param, "pager") == 0)
{ {
if (value && strcasecmp(value, "always") == 0) if (value && pg_strcasecmp(value, "always") == 0)
popt->topt.pager = 2; popt->topt.pager = 2;
else if (popt->topt.pager == 1) else if (popt->topt.pager == 1)
popt->topt.pager = 0; popt->topt.pager = 0;

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.85 2004/03/21 22:29:11 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.86 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
@ -985,17 +985,17 @@ is_transact_command(const char *query)
while (isalpha((unsigned char) query[wordlen])) while (isalpha((unsigned char) query[wordlen]))
wordlen++; wordlen++;
if (wordlen == 5 && strncasecmp(query, "begin", 5) == 0) if (wordlen == 5 && pg_strncasecmp(query, "begin", 5) == 0)
return true; return true;
if (wordlen == 6 && strncasecmp(query, "commit", 6) == 0) if (wordlen == 6 && pg_strncasecmp(query, "commit", 6) == 0)
return true; return true;
if (wordlen == 8 && strncasecmp(query, "rollback", 8) == 0) if (wordlen == 8 && pg_strncasecmp(query, "rollback", 8) == 0)
return true; return true;
if (wordlen == 5 && strncasecmp(query, "abort", 5) == 0) if (wordlen == 5 && pg_strncasecmp(query, "abort", 5) == 0)
return true; return true;
if (wordlen == 3 && strncasecmp(query, "end", 3) == 0) if (wordlen == 3 && pg_strncasecmp(query, "end", 3) == 0)
return true; return true;
if (wordlen == 5 && strncasecmp(query, "start", 5) == 0) if (wordlen == 5 && pg_strncasecmp(query, "start", 5) == 0)
return true; return true;
return false; return false;

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.46 2004/04/21 00:34:18 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.47 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "copy.h" #include "copy.h"
@ -27,7 +27,6 @@
#include "stringutils.h" #include "stringutils.h"
#if defined(WIN32) && (!defined(__MINGW32__)) #if defined(WIN32) && (!defined(__MINGW32__))
#define strcasecmp(x,y) stricmp(x,y)
#define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask)) #define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
#define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR) #define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)
#endif #endif
@ -133,7 +132,7 @@ parse_slash_copy(const char *args)
#ifdef NOT_USED #ifdef NOT_USED
/* this is not implemented yet */ /* this is not implemented yet */
if (strcasecmp(token, "binary") == 0) if (pg_strcasecmp(token, "binary") == 0)
{ {
result->binary = true; result->binary = true;
token = strtokx(NULL, whitespace, ".,()", "\"", token = strtokx(NULL, whitespace, ".,()", "\"",
@ -200,11 +199,11 @@ parse_slash_copy(const char *args)
/* /*
* Allows old COPY syntax for backward compatibility 2002-06-19 * Allows old COPY syntax for backward compatibility 2002-06-19
*/ */
if (strcasecmp(token, "with") == 0) if (pg_strcasecmp(token, "with") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, NULL, token = strtokx(NULL, whitespace, NULL, NULL,
0, false, pset.encoding); 0, false, pset.encoding);
if (!token || strcasecmp(token, "oids") != 0) if (!token || pg_strcasecmp(token, "oids") != 0)
goto error; goto error;
result->oids = true; result->oids = true;
@ -214,9 +213,9 @@ parse_slash_copy(const char *args)
goto error; goto error;
} }
if (strcasecmp(token, "from") == 0) if (pg_strcasecmp(token, "from") == 0)
result->from = true; result->from = true;
else if (strcasecmp(token, "to") == 0) else if (pg_strcasecmp(token, "to") == 0)
result->from = false; result->from = false;
else else
goto error; goto error;
@ -226,14 +225,14 @@ parse_slash_copy(const char *args)
if (!token) if (!token)
goto error; goto error;
if (strcasecmp(token, "stdin") == 0 || if (pg_strcasecmp(token, "stdin") == 0 ||
strcasecmp(token, "stdout") == 0) pg_strcasecmp(token, "stdout") == 0)
{ {
result->psql_inout = false; result->psql_inout = false;
result->file = NULL; result->file = NULL;
} }
else if (strcasecmp(token, "pstdin") == 0 || else if (pg_strcasecmp(token, "pstdin") == 0 ||
strcasecmp(token, "pstdout") == 0) pg_strcasecmp(token, "pstdout") == 0)
{ {
result->psql_inout = true; result->psql_inout = true;
result->file = NULL; result->file = NULL;
@ -251,14 +250,14 @@ parse_slash_copy(const char *args)
/* /*
* Allows old COPY syntax for backward compatibility 2002-06-19 * Allows old COPY syntax for backward compatibility 2002-06-19
*/ */
if (token && strcasecmp(token, "using") == 0) if (token && pg_strcasecmp(token, "using") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, NULL, token = strtokx(NULL, whitespace, NULL, NULL,
0, false, pset.encoding); 0, false, pset.encoding);
if (!(token && strcasecmp(token, "delimiters") == 0)) if (!(token && pg_strcasecmp(token, "delimiters") == 0))
goto error; goto error;
} }
if (token && strcasecmp(token, "delimiters") == 0) if (token && pg_strcasecmp(token, "delimiters") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
@ -275,7 +274,7 @@ parse_slash_copy(const char *args)
* WITH is optional. Also, the backend will allow WITH followed by * WITH is optional. Also, the backend will allow WITH followed by
* nothing, so we do too. * nothing, so we do too.
*/ */
if (strcasecmp(token, "with") == 0) if (pg_strcasecmp(token, "with") == 0)
token = strtokx(NULL, whitespace, NULL, NULL, token = strtokx(NULL, whitespace, NULL, NULL,
0, false, pset.encoding); 0, false, pset.encoding);
@ -286,19 +285,19 @@ parse_slash_copy(const char *args)
fetch_next = true; fetch_next = true;
/* someday allow BINARY here */ /* someday allow BINARY here */
if (strcasecmp(token, "oids") == 0) if (pg_strcasecmp(token, "oids") == 0)
{ {
result->oids = true; result->oids = true;
} }
else if (strcasecmp(token, "csv") == 0) else if (pg_strcasecmp(token, "csv") == 0)
{ {
result->csv_mode = true; result->csv_mode = true;
} }
else if (strcasecmp(token, "delimiter") == 0) else if (pg_strcasecmp(token, "delimiter") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token && strcasecmp(token, "as") == 0) if (token && pg_strcasecmp(token, "as") == 0)
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token) if (token)
@ -306,11 +305,11 @@ parse_slash_copy(const char *args)
else else
goto error; goto error;
} }
else if (strcasecmp(token, "null") == 0) else if (pg_strcasecmp(token, "null") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token && strcasecmp(token, "as") == 0) if (token && pg_strcasecmp(token, "as") == 0)
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token) if (token)
@ -318,11 +317,11 @@ parse_slash_copy(const char *args)
else else
goto error; goto error;
} }
else if (strcasecmp(token, "quote") == 0) else if (pg_strcasecmp(token, "quote") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token && strcasecmp(token, "as") == 0) if (token && pg_strcasecmp(token, "as") == 0)
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token) if (token)
@ -330,11 +329,11 @@ parse_slash_copy(const char *args)
else else
goto error; goto error;
} }
else if (strcasecmp(token, "escape") == 0) else if (pg_strcasecmp(token, "escape") == 0)
{ {
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token && strcasecmp(token, "as") == 0) if (token && pg_strcasecmp(token, "as") == 0)
token = strtokx(NULL, whitespace, NULL, "'", token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding); '\\', false, pset.encoding);
if (token) if (token)
@ -342,11 +341,11 @@ parse_slash_copy(const char *args)
else else
goto error; goto error;
} }
else if (strcasecmp(token, "force") == 0) else if (pg_strcasecmp(token, "force") == 0)
{ {
token = strtokx(NULL, whitespace, ",", "\"", token = strtokx(NULL, whitespace, ",", "\"",
0, false, pset.encoding); 0, false, pset.encoding);
if (strcasecmp(token, "quote") == 0) if (pg_strcasecmp(token, "quote") == 0)
{ {
/* handle column list */ /* handle column list */
fetch_next = false; fetch_next = false;
@ -367,11 +366,11 @@ parse_slash_copy(const char *args)
xstrcat(&result->force_quote_list, token); xstrcat(&result->force_quote_list, token);
} }
} }
else if (strcasecmp(token, "not") == 0) else if (pg_strcasecmp(token, "not") == 0)
{ {
token = strtokx(NULL, whitespace, ",", "\"", token = strtokx(NULL, whitespace, ",", "\"",
0, false, pset.encoding); 0, false, pset.encoding);
if (strcasecmp(token, "null") != 0) if (pg_strcasecmp(token, "null") != 0)
goto error; goto error;
/* handle column list */ /* handle column list */
fetch_next = false; fetch_next = false;

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.97 2004/04/22 17:38:16 neilc Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.98 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
@ -1718,7 +1718,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
else if (!inquotes && isupper((unsigned char) *cp)) else if (!inquotes && isupper((unsigned char) *cp))
{ {
appendPQExpBufferChar(&namebuf, appendPQExpBufferChar(&namebuf,
tolower((unsigned char) *cp)); pg_tolower((unsigned char) *cp));
cp++; cp++;
} }
else if (!inquotes && *cp == '*') else if (!inquotes && *cp == '*')

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.86 2004/03/22 03:38:24 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.87 2004/05/07 00:24:58 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
@ -317,7 +317,7 @@ helpSQL(const char *topic, unsigned short int pager)
/* Count newlines for pager */ /* Count newlines for pager */
for (i = 0; QL_HELP[i].cmd; i++) for (i = 0; QL_HELP[i].cmd; i++)
{ {
if (strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, "*") == 0) strcmp(topic, "*") == 0)
{ {
nl_count += 5; nl_count += 5;
@ -325,7 +325,7 @@ helpSQL(const char *topic, unsigned short int pager)
if (*ch == '\n') if (*ch == '\n')
nl_count++; nl_count++;
/* If we have an exact match, exit. Fixes \h SELECT */ /* If we have an exact match, exit. Fixes \h SELECT */
if (strcasecmp(topic, QL_HELP[i].cmd) == 0) if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break; break;
} }
} }
@ -334,7 +334,7 @@ helpSQL(const char *topic, unsigned short int pager)
for (i = 0; QL_HELP[i].cmd; i++) for (i = 0; QL_HELP[i].cmd; i++)
{ {
if (strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, "*") == 0) strcmp(topic, "*") == 0)
{ {
help_found = true; help_found = true;
@ -345,7 +345,7 @@ helpSQL(const char *topic, unsigned short int pager)
gettext(QL_HELP[i].help), gettext(QL_HELP[i].help),
gettext(QL_HELP[i].syntax)); gettext(QL_HELP[i].syntax));
/* If we have an exact match, exit. Fixes \h SELECT */ /* If we have an exact match, exit. Fixes \h SELECT */
if (strcasecmp(topic, QL_HELP[i].cmd) == 0) if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break; break;
} }
} }

View File

@ -31,7 +31,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.2 2004/02/24 21:45:18 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.3 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1374,10 +1374,7 @@ psql_scan_slash_option(PsqlScanState state,
else else
{ {
if (!inquotes && type == OT_SQLID) if (!inquotes && type == OT_SQLID)
{ *cp = pg_tolower((unsigned char) *cp);
if (isupper((unsigned char) *cp))
*cp = tolower((unsigned char) *cp);
}
cp += PQmblen(cp, pset.encoding); cp += PQmblen(cp, pset.encoding);
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.104 2004/04/05 03:02:09 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.105 2004/05/07 00:24:58 tgl Exp $
*/ */
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -617,9 +617,9 @@ psql_completion(char *text, int start, int end)
/* CREATE or DROP but not ALTER TABLE sth DROP */ /* CREATE or DROP but not ALTER TABLE sth DROP */
/* complete with something you can create or drop */ /* complete with something you can create or drop */
else if (strcasecmp(prev_wd, "CREATE") == 0 || else if (pg_strcasecmp(prev_wd, "CREATE") == 0 ||
(strcasecmp(prev_wd, "DROP") == 0 && (pg_strcasecmp(prev_wd, "DROP") == 0 &&
strcasecmp(prev3_wd, "TABLE") != 0)) pg_strcasecmp(prev3_wd, "TABLE") != 0))
matches = completion_matches(text, create_command_generator); matches = completion_matches(text, create_command_generator);
/* ALTER */ /* ALTER */
@ -628,8 +628,8 @@ psql_completion(char *text, int start, int end)
* complete with what you can alter (TABLE, GROUP, USER, ...) unless * complete with what you can alter (TABLE, GROUP, USER, ...) unless
* we're in ALTER TABLE sth ALTER * we're in ALTER TABLE sth ALTER
*/ */
else if (strcasecmp(prev_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev_wd, "ALTER") == 0 &&
strcasecmp(prev3_wd, "TABLE") != 0) pg_strcasecmp(prev3_wd, "TABLE") != 0)
{ {
static const char *const list_ALTER[] = static const char *const list_ALTER[] =
{"DATABASE", "GROUP", "SCHEMA", "TABLE", "TRIGGER", "USER", NULL}; {"DATABASE", "GROUP", "SCHEMA", "TABLE", "TRIGGER", "USER", NULL};
@ -638,8 +638,8 @@ psql_completion(char *text, int start, int end)
} }
/* ALTER DATABASE <name> */ /* ALTER DATABASE <name> */
else if (strcasecmp(prev3_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
strcasecmp(prev2_wd, "DATABASE") == 0) pg_strcasecmp(prev2_wd, "DATABASE") == 0)
{ {
static const char *const list_ALTERDATABASE[] = static const char *const list_ALTERDATABASE[] =
{"RESET", "SET", "RENAME TO", NULL}; {"RESET", "SET", "RENAME TO", NULL};
@ -647,24 +647,24 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_ALTERDATABASE); COMPLETE_WITH_LIST(list_ALTERDATABASE);
} }
/* ALTER TRIGGER <name>, add ON */ /* ALTER TRIGGER <name>, add ON */
else if (strcasecmp(prev3_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
strcasecmp(prev2_wd, "TRIGGER") == 0) pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
/* /*
* If we have ALTER TRIGGER <sth> ON, then add the correct tablename * If we have ALTER TRIGGER <sth> ON, then add the correct tablename
*/ */
else if (strcasecmp(prev4_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
strcasecmp(prev3_wd, "TRIGGER") == 0 && pg_strcasecmp(prev3_wd, "TRIGGER") == 0 &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* /*
* If we detect ALTER TABLE <name>, suggest either ADD, DROP, ALTER, * If we detect ALTER TABLE <name>, suggest either ADD, DROP, ALTER,
* RENAME, or OWNER * RENAME, or OWNER
*/ */
else if (strcasecmp(prev3_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
strcasecmp(prev2_wd, "TABLE") == 0) pg_strcasecmp(prev2_wd, "TABLE") == 0)
{ {
static const char *const list_ALTER2[] = static const char *const list_ALTER2[] =
{"ADD", "ALTER", "DROP", "RENAME", "OWNER TO", NULL}; {"ADD", "ALTER", "DROP", "RENAME", "OWNER TO", NULL};
@ -672,14 +672,14 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_ALTER2); COMPLETE_WITH_LIST(list_ALTER2);
} }
/* If we have TABLE <sth> ALTER|RENAME, provide list of columns */ /* If we have TABLE <sth> ALTER|RENAME, provide list of columns */
else if (strcasecmp(prev3_wd, "TABLE") == 0 && else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
(strcasecmp(prev_wd, "ALTER") == 0 || (pg_strcasecmp(prev_wd, "ALTER") == 0 ||
strcasecmp(prev_wd, "RENAME") == 0)) pg_strcasecmp(prev_wd, "RENAME") == 0))
COMPLETE_WITH_ATTR(prev2_wd); COMPLETE_WITH_ATTR(prev2_wd);
/* If we have TABLE <sth> DROP, provide COLUMN or CONSTRAINT */ /* If we have TABLE <sth> DROP, provide COLUMN or CONSTRAINT */
else if (strcasecmp(prev3_wd, "TABLE") == 0 && else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
strcasecmp(prev_wd, "DROP") == 0) pg_strcasecmp(prev_wd, "DROP") == 0)
{ {
static const char *const list_TABLEDROP[] = static const char *const list_TABLEDROP[] =
{"COLUMN", "CONSTRAINT", NULL}; {"COLUMN", "CONSTRAINT", NULL};
@ -687,14 +687,14 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_TABLEDROP); COMPLETE_WITH_LIST(list_TABLEDROP);
} }
/* If we have TABLE <sth> DROP COLUMN, provide list of columns */ /* If we have TABLE <sth> DROP COLUMN, provide list of columns */
else if (strcasecmp(prev4_wd, "TABLE") == 0 && else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
strcasecmp(prev2_wd, "DROP") == 0 && pg_strcasecmp(prev2_wd, "DROP") == 0 &&
strcasecmp(prev_wd, "COLUMN") == 0) pg_strcasecmp(prev_wd, "COLUMN") == 0)
COMPLETE_WITH_ATTR(prev3_wd); COMPLETE_WITH_ATTR(prev3_wd);
/* complete ALTER GROUP <foo> with ADD or DROP */ /* complete ALTER GROUP <foo> with ADD or DROP */
else if (strcasecmp(prev3_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
strcasecmp(prev2_wd, "GROUP") == 0) pg_strcasecmp(prev2_wd, "GROUP") == 0)
{ {
static const char *const list_ALTERGROUP[] = static const char *const list_ALTERGROUP[] =
{"ADD", "DROP", NULL}; {"ADD", "DROP", NULL};
@ -702,32 +702,32 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_ALTERGROUP); COMPLETE_WITH_LIST(list_ALTERGROUP);
} }
/* complete ALTER GROUP <foo> ADD|DROP with USER */ /* complete ALTER GROUP <foo> ADD|DROP with USER */
else if (strcasecmp(prev4_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
strcasecmp(prev3_wd, "GROUP") == 0 && pg_strcasecmp(prev3_wd, "GROUP") == 0 &&
(strcasecmp(prev_wd, "ADD") == 0 || (pg_strcasecmp(prev_wd, "ADD") == 0 ||
strcasecmp(prev_wd, "DROP") == 0)) pg_strcasecmp(prev_wd, "DROP") == 0))
COMPLETE_WITH_CONST("USER"); COMPLETE_WITH_CONST("USER");
/* complete {ALTER} GROUP <foo> ADD|DROP USER with a user name */ /* complete {ALTER} GROUP <foo> ADD|DROP USER with a user name */
else if (strcasecmp(prev4_wd, "GROUP") == 0 && else if (pg_strcasecmp(prev4_wd, "GROUP") == 0 &&
(strcasecmp(prev2_wd, "ADD") == 0 || (pg_strcasecmp(prev2_wd, "ADD") == 0 ||
strcasecmp(prev2_wd, "DROP") == 0) && pg_strcasecmp(prev2_wd, "DROP") == 0) &&
strcasecmp(prev_wd, "USER") == 0) pg_strcasecmp(prev_wd, "USER") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_users); COMPLETE_WITH_QUERY(Query_for_list_of_users);
/* ANALYZE */ /* ANALYZE */
/* If the previous word is ANALYZE, produce list of tables. */ /* If the previous word is ANALYZE, produce list of tables. */
else if (strcasecmp(prev_wd, "ANALYZE") == 0) else if (pg_strcasecmp(prev_wd, "ANALYZE") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* If we have ANALYZE <table>, complete with semicolon. */ /* If we have ANALYZE <table>, complete with semicolon. */
else if (strcasecmp(prev2_wd, "ANALYZE") == 0) else if (pg_strcasecmp(prev2_wd, "ANALYZE") == 0)
COMPLETE_WITH_CONST(";"); COMPLETE_WITH_CONST(";");
/* BEGIN, COMMIT, ROLLBACK, ABORT, */ /* BEGIN, COMMIT, ROLLBACK, ABORT, */
else if (strcasecmp(prev_wd, "BEGIN") == 0 || else if (pg_strcasecmp(prev_wd, "BEGIN") == 0 ||
strcasecmp(prev_wd, "END") == 0 || pg_strcasecmp(prev_wd, "END") == 0 ||
strcasecmp(prev_wd, "COMMIT") == 0 || pg_strcasecmp(prev_wd, "COMMIT") == 0 ||
strcasecmp(prev_wd, "ROLLBACK") == 0 || pg_strcasecmp(prev_wd, "ROLLBACK") == 0 ||
strcasecmp(prev_wd, "ABORT") == 0) pg_strcasecmp(prev_wd, "ABORT") == 0)
{ {
static const char * const list_TRANS[] = static const char * const list_TRANS[] =
{"WORK", "TRANSACTION", NULL}; {"WORK", "TRANSACTION", NULL};
@ -736,28 +736,28 @@ psql_completion(char *text, int start, int end)
} }
/* CLUSTER */ /* CLUSTER */
/* If the previous word is CLUSTER, produce list of indexes. */ /* If the previous word is CLUSTER, produce list of indexes. */
else if (strcasecmp(prev_wd, "CLUSTER") == 0) else if (pg_strcasecmp(prev_wd, "CLUSTER") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
/* If we have CLUSTER <sth>, then add "ON" */ /* If we have CLUSTER <sth>, then add "ON" */
else if (strcasecmp(prev2_wd, "CLUSTER") == 0) else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0)
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
/* /*
* If we have CLUSTER <sth> ON, then add the correct tablename as * If we have CLUSTER <sth> ON, then add the correct tablename as
* well. * well.
*/ */
else if (strcasecmp(prev3_wd, "CLUSTER") == 0 && else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
{ {
completion_info_charp = prev2_wd; completion_info_charp = prev2_wd;
COMPLETE_WITH_QUERY(Query_for_table_owning_index); COMPLETE_WITH_QUERY(Query_for_table_owning_index);
} }
/* COMMENT */ /* COMMENT */
else if (strcasecmp(prev_wd, "COMMENT") == 0) else if (pg_strcasecmp(prev_wd, "COMMENT") == 0)
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
else if (strcasecmp(prev2_wd, "COMMENT") == 0 && else if (pg_strcasecmp(prev2_wd, "COMMENT") == 0 &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
{ {
static const char *const list_COMMENT[] = static const char *const list_COMMENT[] =
{"DATABASE", "INDEX", "RULE", "SCHEMA", "SEQUENCE", "TABLE", {"DATABASE", "INDEX", "RULE", "SCHEMA", "SEQUENCE", "TABLE",
@ -766,8 +766,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_COMMENT); COMPLETE_WITH_LIST(list_COMMENT);
} }
else if (strcasecmp(prev4_wd, "COMMENT") == 0 && else if (pg_strcasecmp(prev4_wd, "COMMENT") == 0 &&
strcasecmp(prev3_wd, "ON") == 0) pg_strcasecmp(prev3_wd, "ON") == 0)
COMPLETE_WITH_CONST("IS"); COMPLETE_WITH_CONST("IS");
/* COPY */ /* COPY */
@ -776,15 +776,15 @@ psql_completion(char *text, int start, int end)
* If we have COPY [BINARY] (which you'd have to type yourself), offer * If we have COPY [BINARY] (which you'd have to type yourself), offer
* list of tables (Also cover the analogous backslash command) * list of tables (Also cover the analogous backslash command)
*/ */
else if (strcasecmp(prev_wd, "COPY") == 0 || else if (pg_strcasecmp(prev_wd, "COPY") == 0 ||
strcasecmp(prev_wd, "\\copy") == 0 || pg_strcasecmp(prev_wd, "\\copy") == 0 ||
(strcasecmp(prev2_wd, "COPY") == 0 && (pg_strcasecmp(prev2_wd, "COPY") == 0 &&
strcasecmp(prev_wd, "BINARY") == 0)) pg_strcasecmp(prev_wd, "BINARY") == 0))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */ /* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */
else if (strcasecmp(prev2_wd, "COPY") == 0 || else if (pg_strcasecmp(prev2_wd, "COPY") == 0 ||
strcasecmp(prev2_wd, "\\copy") == 0 || pg_strcasecmp(prev2_wd, "\\copy") == 0 ||
strcasecmp(prev2_wd, "BINARY") == 0) pg_strcasecmp(prev2_wd, "BINARY") == 0)
{ {
static const char *const list_FROMTO[] = static const char *const list_FROMTO[] =
{"FROM", "TO", NULL}; {"FROM", "TO", NULL};
@ -794,32 +794,32 @@ psql_completion(char *text, int start, int end)
/* CREATE INDEX */ /* CREATE INDEX */
/* First off we complete CREATE UNIQUE with "INDEX" */ /* First off we complete CREATE UNIQUE with "INDEX" */
else if (strcasecmp(prev2_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev2_wd, "CREATE") == 0 &&
strcasecmp(prev_wd, "UNIQUE") == 0) pg_strcasecmp(prev_wd, "UNIQUE") == 0)
COMPLETE_WITH_CONST("INDEX"); COMPLETE_WITH_CONST("INDEX");
/* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */ /* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */
else if (strcasecmp(prev2_wd, "INDEX") == 0 && else if (pg_strcasecmp(prev2_wd, "INDEX") == 0 &&
(strcasecmp(prev3_wd, "CREATE") == 0 || (pg_strcasecmp(prev3_wd, "CREATE") == 0 ||
strcasecmp(prev3_wd, "UNIQUE") == 0)) pg_strcasecmp(prev3_wd, "UNIQUE") == 0))
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
/* Complete ... INDEX <name> ON with a list of tables */ /* Complete ... INDEX <name> ON with a list of tables */
else if (strcasecmp(prev3_wd, "INDEX") == 0 && else if (pg_strcasecmp(prev3_wd, "INDEX") == 0 &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* /*
* Complete INDEX <name> ON <table> with a list of table columns * Complete INDEX <name> ON <table> with a list of table columns
* (which should really be in parens) * (which should really be in parens)
*/ */
else if (strcasecmp(prev4_wd, "INDEX") == 0 && else if (pg_strcasecmp(prev4_wd, "INDEX") == 0 &&
strcasecmp(prev2_wd, "ON") == 0) pg_strcasecmp(prev2_wd, "ON") == 0)
COMPLETE_WITH_ATTR(prev_wd); COMPLETE_WITH_ATTR(prev_wd);
/* same if you put in USING */ /* same if you put in USING */
else if (strcasecmp(prev4_wd, "ON") == 0 && else if (pg_strcasecmp(prev4_wd, "ON") == 0 &&
strcasecmp(prev2_wd, "USING") == 0) pg_strcasecmp(prev2_wd, "USING") == 0)
COMPLETE_WITH_ATTR(prev3_wd); COMPLETE_WITH_ATTR(prev3_wd);
/* Complete USING with an index method */ /* Complete USING with an index method */
else if (strcasecmp(prev_wd, "USING") == 0) else if (pg_strcasecmp(prev_wd, "USING") == 0)
{ {
static const char *const index_mth[] = static const char *const index_mth[] =
{"BTREE", "RTREE", "HASH", "GIST", NULL}; {"BTREE", "RTREE", "HASH", "GIST", NULL};
@ -829,18 +829,18 @@ psql_completion(char *text, int start, int end)
/* CREATE RULE */ /* CREATE RULE */
/* Complete "CREATE RULE <sth>" with "AS" */ /* Complete "CREATE RULE <sth>" with "AS" */
else if (strcasecmp(prev3_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
strcasecmp(prev2_wd, "RULE") == 0) pg_strcasecmp(prev2_wd, "RULE") == 0)
COMPLETE_WITH_CONST("AS"); COMPLETE_WITH_CONST("AS");
/* Complete "CREATE RULE <sth> AS with "ON" */ /* Complete "CREATE RULE <sth> AS with "ON" */
else if (strcasecmp(prev4_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
strcasecmp(prev3_wd, "RULE") == 0 && pg_strcasecmp(prev3_wd, "RULE") == 0 &&
strcasecmp(prev_wd, "AS") == 0) pg_strcasecmp(prev_wd, "AS") == 0)
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
/* Complete "RULE * AS ON" with SELECT|UPDATE|DELETE|INSERT */ /* Complete "RULE * AS ON" with SELECT|UPDATE|DELETE|INSERT */
else if (strcasecmp(prev4_wd, "RULE") == 0 && else if (pg_strcasecmp(prev4_wd, "RULE") == 0 &&
strcasecmp(prev2_wd, "AS") == 0 && pg_strcasecmp(prev2_wd, "AS") == 0 &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
{ {
static const char *const rule_events[] = static const char *const rule_events[] =
{"SELECT", "UPDATE", "INSERT", "DELETE", NULL}; {"SELECT", "UPDATE", "INSERT", "DELETE", NULL};
@ -848,21 +848,21 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(rule_events); COMPLETE_WITH_LIST(rule_events);
} }
/* Complete "AS ON <sth with a 'T' :)>" with a "TO" */ /* Complete "AS ON <sth with a 'T' :)>" with a "TO" */
else if (strcasecmp(prev3_wd, "AS") == 0 && else if (pg_strcasecmp(prev3_wd, "AS") == 0 &&
strcasecmp(prev2_wd, "ON") == 0 && pg_strcasecmp(prev2_wd, "ON") == 0 &&
(toupper((unsigned char) prev_wd[4]) == 'T' || (toupper((unsigned char) prev_wd[4]) == 'T' ||
toupper((unsigned char) prev_wd[5]) == 'T')) toupper((unsigned char) prev_wd[5]) == 'T'))
COMPLETE_WITH_CONST("TO"); COMPLETE_WITH_CONST("TO");
/* Complete "AS ON <sth> TO" with a table name */ /* Complete "AS ON <sth> TO" with a table name */
else if (strcasecmp(prev4_wd, "AS") == 0 && else if (pg_strcasecmp(prev4_wd, "AS") == 0 &&
strcasecmp(prev3_wd, "ON") == 0 && pg_strcasecmp(prev3_wd, "ON") == 0 &&
strcasecmp(prev_wd, "TO") == 0) pg_strcasecmp(prev_wd, "TO") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* CREATE TABLE */ /* CREATE TABLE */
/* Complete CREATE TEMP with "TABLE" */ /* Complete CREATE TEMP with "TABLE" */
else if (strcasecmp(prev2_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev2_wd, "CREATE") == 0 &&
strcasecmp(prev_wd, "TEMP") == 0) pg_strcasecmp(prev_wd, "TEMP") == 0)
COMPLETE_WITH_CONST("TABLE"); COMPLETE_WITH_CONST("TABLE");
/* CREATE TRIGGER */ /* CREATE TRIGGER */
@ -870,13 +870,13 @@ psql_completion(char *text, int start, int end)
/* CREATE VIEW */ /* CREATE VIEW */
/* Complete "CREATE VIEW <name>" with "AS" */ /* Complete "CREATE VIEW <name>" with "AS" */
else if (strcasecmp(prev3_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
strcasecmp(prev2_wd, "VIEW") == 0) pg_strcasecmp(prev2_wd, "VIEW") == 0)
COMPLETE_WITH_CONST("AS"); COMPLETE_WITH_CONST("AS");
/* Complete "CREATE VIEW <sth> AS with "SELECT" */ /* Complete "CREATE VIEW <sth> AS with "SELECT" */
else if (strcasecmp(prev4_wd, "CREATE") == 0 && else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
strcasecmp(prev3_wd, "VIEW") == 0 && pg_strcasecmp(prev3_wd, "VIEW") == 0 &&
strcasecmp(prev_wd, "AS") == 0) pg_strcasecmp(prev_wd, "AS") == 0)
COMPLETE_WITH_CONST("SELECT"); COMPLETE_WITH_CONST("SELECT");
/* DELETE */ /* DELETE */
@ -885,19 +885,19 @@ psql_completion(char *text, int start, int end)
* Complete DELETE with FROM (only if the word before that is not "ON" * Complete DELETE with FROM (only if the word before that is not "ON"
* (cf. rules) or "BEFORE" or "AFTER" (cf. triggers) or GRANT) * (cf. rules) or "BEFORE" or "AFTER" (cf. triggers) or GRANT)
*/ */
else if (strcasecmp(prev_wd, "DELETE") == 0 && else if (pg_strcasecmp(prev_wd, "DELETE") == 0 &&
!(strcasecmp(prev2_wd, "ON") == 0 || !(pg_strcasecmp(prev2_wd, "ON") == 0 ||
strcasecmp(prev2_wd, "GRANT") == 0 || pg_strcasecmp(prev2_wd, "GRANT") == 0 ||
strcasecmp(prev2_wd, "BEFORE") == 0 || pg_strcasecmp(prev2_wd, "BEFORE") == 0 ||
strcasecmp(prev2_wd, "AFTER") == 0)) pg_strcasecmp(prev2_wd, "AFTER") == 0))
COMPLETE_WITH_CONST("FROM"); COMPLETE_WITH_CONST("FROM");
/* Complete DELETE FROM with a list of tables */ /* Complete DELETE FROM with a list of tables */
else if (strcasecmp(prev2_wd, "DELETE") == 0 && else if (pg_strcasecmp(prev2_wd, "DELETE") == 0 &&
strcasecmp(prev_wd, "FROM") == 0) pg_strcasecmp(prev_wd, "FROM") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */ /* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */
else if (strcasecmp(prev3_wd, "DELETE") == 0 && else if (pg_strcasecmp(prev3_wd, "DELETE") == 0 &&
strcasecmp(prev2_wd, "FROM") == 0) pg_strcasecmp(prev2_wd, "FROM") == 0)
COMPLETE_WITH_CONST("WHERE"); COMPLETE_WITH_CONST("WHERE");
/* EXPLAIN */ /* EXPLAIN */
@ -906,15 +906,15 @@ psql_completion(char *text, int start, int end)
* Complete EXPLAIN [VERBOSE] (which you'd have to type yourself) with * Complete EXPLAIN [VERBOSE] (which you'd have to type yourself) with
* the list of SQL commands * the list of SQL commands
*/ */
else if (strcasecmp(prev_wd, "EXPLAIN") == 0 || else if (pg_strcasecmp(prev_wd, "EXPLAIN") == 0 ||
(strcasecmp(prev2_wd, "EXPLAIN") == 0 && (pg_strcasecmp(prev2_wd, "EXPLAIN") == 0 &&
strcasecmp(prev_wd, "VERBOSE") == 0)) pg_strcasecmp(prev_wd, "VERBOSE") == 0))
COMPLETE_WITH_LIST(sql_commands); COMPLETE_WITH_LIST(sql_commands);
/* FETCH && MOVE */ /* FETCH && MOVE */
/* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */ /* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
else if (strcasecmp(prev_wd, "FETCH") == 0 || else if (pg_strcasecmp(prev_wd, "FETCH") == 0 ||
strcasecmp(prev_wd, "MOVE") == 0) pg_strcasecmp(prev_wd, "MOVE") == 0)
{ {
static const char * const list_FETCH1[] = static const char * const list_FETCH1[] =
{"FORWARD", "BACKWARD", "RELATIVE", NULL}; {"FORWARD", "BACKWARD", "RELATIVE", NULL};
@ -922,8 +922,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_FETCH1); COMPLETE_WITH_LIST(list_FETCH1);
} }
/* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */ /* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */
else if (strcasecmp(prev2_wd, "FETCH") == 0 || else if (pg_strcasecmp(prev2_wd, "FETCH") == 0 ||
strcasecmp(prev2_wd, "MOVE") == 0) pg_strcasecmp(prev2_wd, "MOVE") == 0)
{ {
static const char * const list_FETCH2[] = static const char * const list_FETCH2[] =
{"ALL", "NEXT", "PRIOR", NULL}; {"ALL", "NEXT", "PRIOR", NULL};
@ -935,8 +935,8 @@ psql_completion(char *text, int start, int end)
* Complete FETCH <sth1> <sth2> with "FROM" or "TO". (Is there a * Complete FETCH <sth1> <sth2> with "FROM" or "TO". (Is there a
* difference? If not, remove one.) * difference? If not, remove one.)
*/ */
else if (strcasecmp(prev3_wd, "FETCH") == 0 || else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
strcasecmp(prev3_wd, "MOVE") == 0) pg_strcasecmp(prev3_wd, "MOVE") == 0)
{ {
static const char * const list_FROMTO[] = static const char * const list_FROMTO[] =
{"FROM", "TO", NULL}; {"FROM", "TO", NULL};
@ -946,8 +946,8 @@ psql_completion(char *text, int start, int end)
/* GRANT && REVOKE*/ /* GRANT && REVOKE*/
/* Complete GRANT/REVOKE with a list of privileges */ /* Complete GRANT/REVOKE with a list of privileges */
else if (strcasecmp(prev_wd, "GRANT") == 0 || else if (pg_strcasecmp(prev_wd, "GRANT") == 0 ||
strcasecmp(prev_wd, "REVOKE") == 0) pg_strcasecmp(prev_wd, "REVOKE") == 0)
{ {
static const char * const list_privileg[] = static const char * const list_privileg[] =
{"SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "REFERENCES", {"SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "REFERENCES",
@ -956,8 +956,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_privileg); COMPLETE_WITH_LIST(list_privileg);
} }
/* Complete GRANT/REVOKE <sth> with "ON" */ /* Complete GRANT/REVOKE <sth> with "ON" */
else if (strcasecmp(prev2_wd, "GRANT") == 0 || else if (pg_strcasecmp(prev2_wd, "GRANT") == 0 ||
strcasecmp(prev2_wd, "REVOKE") == 0) pg_strcasecmp(prev2_wd, "REVOKE") == 0)
COMPLETE_WITH_CONST("ON"); COMPLETE_WITH_CONST("ON");
/* /*
@ -971,9 +971,9 @@ psql_completion(char *text, int start, int end)
* implemented here will only work if the privilege list contains * implemented here will only work if the privilege list contains
* exactly one privilege * exactly one privilege
*/ */
else if ((strcasecmp(prev3_wd, "GRANT") == 0 || else if ((pg_strcasecmp(prev3_wd, "GRANT") == 0 ||
strcasecmp(prev3_wd, "REVOKE") == 0) && pg_strcasecmp(prev3_wd, "REVOKE") == 0) &&
strcasecmp(prev_wd, "ON") == 0) pg_strcasecmp(prev_wd, "ON") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv,
" UNION SELECT 'DATABASE'" " UNION SELECT 'DATABASE'"
" UNION SELECT 'FUNCTION'" " UNION SELECT 'FUNCTION'"
@ -981,17 +981,17 @@ psql_completion(char *text, int start, int end)
" UNION SELECT 'SCHEMA'"); " UNION SELECT 'SCHEMA'");
/* Complete "GRANT/REVOKE * ON * " with "TO" */ /* Complete "GRANT/REVOKE * ON * " with "TO" */
else if ((strcasecmp(prev4_wd, "GRANT") == 0 || else if ((pg_strcasecmp(prev4_wd, "GRANT") == 0 ||
strcasecmp(prev4_wd, "REVOKE") == 0) && pg_strcasecmp(prev4_wd, "REVOKE") == 0) &&
strcasecmp(prev2_wd, "ON") == 0) pg_strcasecmp(prev2_wd, "ON") == 0)
{ {
if (strcasecmp(prev_wd, "DATABASE") == 0) if (pg_strcasecmp(prev_wd, "DATABASE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_databases); COMPLETE_WITH_QUERY(Query_for_list_of_databases);
else if (strcasecmp(prev_wd, "FUNCTION") == 0) else if (pg_strcasecmp(prev_wd, "FUNCTION") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
else if (strcasecmp(prev_wd, "LANGUAGE") == 0) else if (pg_strcasecmp(prev_wd, "LANGUAGE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_languages); COMPLETE_WITH_QUERY(Query_for_list_of_languages);
else if (strcasecmp(prev_wd, "SCHEMA") == 0) else if (pg_strcasecmp(prev_wd, "SCHEMA") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_schemas); COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
else else
COMPLETE_WITH_CONST("TO"); COMPLETE_WITH_CONST("TO");
@ -1005,24 +1005,24 @@ psql_completion(char *text, int start, int end)
/* INSERT */ /* INSERT */
/* Complete INSERT with "INTO" */ /* Complete INSERT with "INTO" */
else if (strcasecmp(prev_wd, "INSERT") == 0) else if (pg_strcasecmp(prev_wd, "INSERT") == 0)
COMPLETE_WITH_CONST("INTO"); COMPLETE_WITH_CONST("INTO");
/* Complete INSERT INTO with table names */ /* Complete INSERT INTO with table names */
else if (strcasecmp(prev2_wd, "INSERT") == 0 && else if (pg_strcasecmp(prev2_wd, "INSERT") == 0 &&
strcasecmp(prev_wd, "INTO") == 0) pg_strcasecmp(prev_wd, "INTO") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* Complete "INSERT INTO <table> (" with attribute names */ /* Complete "INSERT INTO <table> (" with attribute names */
else if (rl_line_buffer[start - 1] == '(' && else if (rl_line_buffer[start - 1] == '(' &&
strcasecmp(prev3_wd, "INSERT") == 0 && pg_strcasecmp(prev3_wd, "INSERT") == 0 &&
strcasecmp(prev2_wd, "INTO") == 0) pg_strcasecmp(prev2_wd, "INTO") == 0)
COMPLETE_WITH_ATTR(prev_wd); COMPLETE_WITH_ATTR(prev_wd);
/* /*
* Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT * Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT
* VALUES" * VALUES"
*/ */
else if (strcasecmp(prev3_wd, "INSERT") == 0 && else if (pg_strcasecmp(prev3_wd, "INSERT") == 0 &&
strcasecmp(prev2_wd, "INTO") == 0) pg_strcasecmp(prev2_wd, "INTO") == 0)
{ {
static const char * const list_INSERT[] = static const char * const list_INSERT[] =
{"DEFAULT VALUES", "SELECT", "VALUES", NULL}; {"DEFAULT VALUES", "SELECT", "VALUES", NULL};
@ -1030,8 +1030,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_INSERT); COMPLETE_WITH_LIST(list_INSERT);
} }
/* Complete INSERT INTO <table> (attribs) with "VALUES" or "SELECT" */ /* Complete INSERT INTO <table> (attribs) with "VALUES" or "SELECT" */
else if (strcasecmp(prev4_wd, "INSERT") == 0 && else if (pg_strcasecmp(prev4_wd, "INSERT") == 0 &&
strcasecmp(prev3_wd, "INTO") == 0 && pg_strcasecmp(prev3_wd, "INTO") == 0 &&
prev_wd[strlen(prev_wd) - 1] == ')') prev_wd[strlen(prev_wd) - 1] == ')')
{ {
static const char * const list_INSERT[] = static const char * const list_INSERT[] =
@ -1041,31 +1041,31 @@ psql_completion(char *text, int start, int end)
} }
/* Insert an open parenthesis after "VALUES" */ /* Insert an open parenthesis after "VALUES" */
else if (strcasecmp(prev_wd, "VALUES") == 0 && else if (pg_strcasecmp(prev_wd, "VALUES") == 0 &&
strcasecmp(prev2_wd, "DEFAULT") != 0) pg_strcasecmp(prev2_wd, "DEFAULT") != 0)
COMPLETE_WITH_CONST("("); COMPLETE_WITH_CONST("(");
/* LOCK */ /* LOCK */
/* Complete LOCK [TABLE] with a list of tables */ /* Complete LOCK [TABLE] with a list of tables */
else if (strcasecmp(prev_wd, "LOCK") == 0 || else if (pg_strcasecmp(prev_wd, "LOCK") == 0 ||
(strcasecmp(prev_wd, "TABLE") == 0 && (pg_strcasecmp(prev_wd, "TABLE") == 0 &&
strcasecmp(prev2_wd, "LOCK") == 0)) pg_strcasecmp(prev2_wd, "LOCK") == 0))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* For the following, handle the case of a single table only for now */ /* For the following, handle the case of a single table only for now */
/* Complete LOCK [TABLE] <table> with "IN" */ /* Complete LOCK [TABLE] <table> with "IN" */
else if ((strcasecmp(prev2_wd, "LOCK") == 0 && else if ((pg_strcasecmp(prev2_wd, "LOCK") == 0 &&
strcasecmp(prev_wd, "TABLE")) || pg_strcasecmp(prev_wd, "TABLE")) ||
(strcasecmp(prev2_wd, "TABLE") == 0 && (pg_strcasecmp(prev2_wd, "TABLE") == 0 &&
strcasecmp(prev3_wd, "LOCK") == 0)) pg_strcasecmp(prev3_wd, "LOCK") == 0))
COMPLETE_WITH_CONST("IN"); COMPLETE_WITH_CONST("IN");
/* Complete LOCK [TABLE] <table> IN with a lock mode */ /* Complete LOCK [TABLE] <table> IN with a lock mode */
else if (strcasecmp(prev_wd, "IN") == 0 && else if (pg_strcasecmp(prev_wd, "IN") == 0 &&
(strcasecmp(prev3_wd, "LOCK") == 0 || (pg_strcasecmp(prev3_wd, "LOCK") == 0 ||
(strcasecmp(prev3_wd, "TABLE") == 0 && (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
strcasecmp(prev4_wd, "LOCK") == 0))) pg_strcasecmp(prev4_wd, "LOCK") == 0)))
{ {
static const char * const lock_modes[] = static const char * const lock_modes[] =
{"ACCESS SHARE MODE", {"ACCESS SHARE MODE",
@ -1078,24 +1078,24 @@ psql_completion(char *text, int start, int end)
} }
/* NOTIFY */ /* NOTIFY */
else if (strcasecmp(prev_wd, "NOTIFY") == 0) else if (pg_strcasecmp(prev_wd, "NOTIFY") == 0)
COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(relname) FROM pg_catalog.pg_listener WHERE substring(pg_catalog.quote_ident(relname),1,%d)='%s'"); COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(relname) FROM pg_catalog.pg_listener WHERE substring(pg_catalog.quote_ident(relname),1,%d)='%s'");
/* REINDEX */ /* REINDEX */
else if (strcasecmp(prev_wd, "REINDEX") == 0) else if (pg_strcasecmp(prev_wd, "REINDEX") == 0)
{ {
static const char * const list_REINDEX[] = static const char * const list_REINDEX[] =
{"TABLE", "DATABASE", "INDEX", NULL}; {"TABLE", "DATABASE", "INDEX", NULL};
COMPLETE_WITH_LIST(list_REINDEX); COMPLETE_WITH_LIST(list_REINDEX);
} }
else if (strcasecmp(prev2_wd, "REINDEX") == 0) else if (pg_strcasecmp(prev2_wd, "REINDEX") == 0)
{ {
if (strcasecmp(prev_wd, "TABLE") == 0) if (pg_strcasecmp(prev_wd, "TABLE") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
else if (strcasecmp(prev_wd, "DATABASE") == 0) else if (pg_strcasecmp(prev_wd, "DATABASE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_databases); COMPLETE_WITH_QUERY(Query_for_list_of_databases);
else if (strcasecmp(prev_wd, "INDEX") == 0) else if (pg_strcasecmp(prev_wd, "INDEX") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
} }
@ -1104,68 +1104,68 @@ psql_completion(char *text, int start, int end)
/* SET, RESET, SHOW */ /* SET, RESET, SHOW */
/* Complete with a variable name */ /* Complete with a variable name */
else if ((strcasecmp(prev_wd, "SET") == 0 && else if ((pg_strcasecmp(prev_wd, "SET") == 0 &&
strcasecmp(prev3_wd, "UPDATE") != 0) || pg_strcasecmp(prev3_wd, "UPDATE") != 0) ||
strcasecmp(prev_wd, "RESET") == 0 || pg_strcasecmp(prev_wd, "RESET") == 0 ||
strcasecmp(prev_wd, "SHOW") == 0) pg_strcasecmp(prev_wd, "SHOW") == 0)
COMPLETE_WITH_LIST(pgsql_variables); COMPLETE_WITH_LIST(pgsql_variables);
/* Complete "SET TRANSACTION" */ /* Complete "SET TRANSACTION" */
else if ((strcasecmp(prev2_wd, "SET") == 0 && else if ((pg_strcasecmp(prev2_wd, "SET") == 0 &&
strcasecmp(prev_wd, "TRANSACTION") == 0) pg_strcasecmp(prev_wd, "TRANSACTION") == 0)
|| (strcasecmp(prev2_wd, "START") == 0 || (pg_strcasecmp(prev2_wd, "START") == 0
&& strcasecmp(prev_wd, "TRANSACTION") == 0) && pg_strcasecmp(prev_wd, "TRANSACTION") == 0)
|| (strcasecmp(prev2_wd, "BEGIN") == 0 || (pg_strcasecmp(prev2_wd, "BEGIN") == 0
&& strcasecmp(prev_wd, "WORK") == 0) && pg_strcasecmp(prev_wd, "WORK") == 0)
|| (strcasecmp(prev2_wd, "BEGIN") == 0 || (pg_strcasecmp(prev2_wd, "BEGIN") == 0
&& strcasecmp(prev_wd, "TRANSACTION") == 0) && pg_strcasecmp(prev_wd, "TRANSACTION") == 0)
|| (strcasecmp(prev4_wd, "SESSION") == 0 || (pg_strcasecmp(prev4_wd, "SESSION") == 0
&& strcasecmp(prev3_wd, "CHARACTERISTICS") == 0 && pg_strcasecmp(prev3_wd, "CHARACTERISTICS") == 0
&& strcasecmp(prev2_wd, "AS") == 0 && pg_strcasecmp(prev2_wd, "AS") == 0
&& strcasecmp(prev_wd, "TRANSACTION") == 0)) && pg_strcasecmp(prev_wd, "TRANSACTION") == 0))
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"ISOLATION", "READ", NULL}; {"ISOLATION", "READ", NULL};
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
else if ((strcasecmp(prev3_wd, "SET") == 0 else if ((pg_strcasecmp(prev3_wd, "SET") == 0
|| strcasecmp(prev3_wd, "START") == 0 || pg_strcasecmp(prev3_wd, "START") == 0
|| (strcasecmp(prev4_wd, "CHARACTERISTICS") == 0 || (pg_strcasecmp(prev4_wd, "CHARACTERISTICS") == 0
&& strcasecmp(prev3_wd, "AS") == 0)) && pg_strcasecmp(prev3_wd, "AS") == 0))
&& strcasecmp(prev2_wd, "TRANSACTION") == 0 && pg_strcasecmp(prev2_wd, "TRANSACTION") == 0
&& strcasecmp(prev_wd, "ISOLATION") == 0) && pg_strcasecmp(prev_wd, "ISOLATION") == 0)
COMPLETE_WITH_CONST("LEVEL"); COMPLETE_WITH_CONST("LEVEL");
else if ((strcasecmp(prev4_wd, "SET") == 0 else if ((pg_strcasecmp(prev4_wd, "SET") == 0
|| strcasecmp(prev4_wd, "START") == 0 || pg_strcasecmp(prev4_wd, "START") == 0
|| strcasecmp(prev4_wd, "AS") == 0) || pg_strcasecmp(prev4_wd, "AS") == 0)
&& strcasecmp(prev3_wd, "TRANSACTION") == 0 && pg_strcasecmp(prev3_wd, "TRANSACTION") == 0
&& strcasecmp(prev2_wd, "ISOLATION") == 0 && pg_strcasecmp(prev2_wd, "ISOLATION") == 0
&& strcasecmp(prev_wd, "LEVEL") == 0) && pg_strcasecmp(prev_wd, "LEVEL") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"READ", "REPEATABLE", "SERIALIZABLE", NULL}; {"READ", "REPEATABLE", "SERIALIZABLE", NULL};
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
else if (strcasecmp(prev4_wd, "TRANSACTION") == 0 && else if (pg_strcasecmp(prev4_wd, "TRANSACTION") == 0 &&
strcasecmp(prev3_wd, "ISOLATION") == 0 && pg_strcasecmp(prev3_wd, "ISOLATION") == 0 &&
strcasecmp(prev2_wd, "LEVEL") == 0 && pg_strcasecmp(prev2_wd, "LEVEL") == 0 &&
strcasecmp(prev_wd, "READ") == 0) pg_strcasecmp(prev_wd, "READ") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"UNCOMMITTED", "COMMITTED", NULL}; {"UNCOMMITTED", "COMMITTED", NULL};
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
else if (strcasecmp(prev4_wd, "TRANSACTION") == 0 && else if (pg_strcasecmp(prev4_wd, "TRANSACTION") == 0 &&
strcasecmp(prev3_wd, "ISOLATION") == 0 && pg_strcasecmp(prev3_wd, "ISOLATION") == 0 &&
strcasecmp(prev2_wd, "LEVEL") == 0 && pg_strcasecmp(prev2_wd, "LEVEL") == 0 &&
strcasecmp(prev_wd, "REPEATABLE") == 0) pg_strcasecmp(prev_wd, "REPEATABLE") == 0)
COMPLETE_WITH_CONST("READ"); COMPLETE_WITH_CONST("READ");
else if ((strcasecmp(prev3_wd, "SET") == 0 || else if ((pg_strcasecmp(prev3_wd, "SET") == 0 ||
strcasecmp(prev3_wd, "AS") == 0) && pg_strcasecmp(prev3_wd, "AS") == 0) &&
strcasecmp(prev2_wd, "TRANSACTION") == 0 && pg_strcasecmp(prev2_wd, "TRANSACTION") == 0 &&
strcasecmp(prev_wd, "READ") == 0) pg_strcasecmp(prev_wd, "READ") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"ONLY", "WRITE", NULL}; {"ONLY", "WRITE", NULL};
@ -1173,8 +1173,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
/* Complete SET CONSTRAINTS <foo> with DEFERRED|IMMEDIATE */ /* Complete SET CONSTRAINTS <foo> with DEFERRED|IMMEDIATE */
else if (strcasecmp(prev3_wd, "SET") == 0 && else if (pg_strcasecmp(prev3_wd, "SET") == 0 &&
strcasecmp(prev2_wd, "CONSTRAINTS") == 0) pg_strcasecmp(prev2_wd, "CONSTRAINTS") == 0)
{ {
static const char * const constraint_list[] = static const char * const constraint_list[] =
{"DEFERRED", "IMMEDIATE", NULL}; {"DEFERRED", "IMMEDIATE", NULL};
@ -1182,8 +1182,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(constraint_list); COMPLETE_WITH_LIST(constraint_list);
} }
/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */ /* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
else if (strcasecmp(prev2_wd, "SET") == 0 && else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
strcasecmp(prev_wd, "SESSION") == 0) pg_strcasecmp(prev_wd, "SESSION") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"AUTHORIZATION", "CHARACTERISTICS AS TRANSACTION", NULL}; {"AUTHORIZATION", "CHARACTERISTICS AS TRANSACTION", NULL};
@ -1191,19 +1191,19 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
/* Complete SET SESSION AUTHORIZATION with username */ /* Complete SET SESSION AUTHORIZATION with username */
else if (strcasecmp(prev3_wd, "SET") == 0 else if (pg_strcasecmp(prev3_wd, "SET") == 0
&& strcasecmp(prev2_wd, "SESSION") == 0 && pg_strcasecmp(prev2_wd, "SESSION") == 0
&& strcasecmp(prev_wd, "AUTHORIZATION") == 0) && pg_strcasecmp(prev_wd, "AUTHORIZATION") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_users); COMPLETE_WITH_QUERY(Query_for_list_of_users);
/* Complete SET <var> with "TO" */ /* Complete SET <var> with "TO" */
else if (strcasecmp(prev2_wd, "SET") == 0 && else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
strcasecmp(prev4_wd, "UPDATE") != 0) pg_strcasecmp(prev4_wd, "UPDATE") != 0)
COMPLETE_WITH_CONST("TO"); COMPLETE_WITH_CONST("TO");
/* Suggest possible variable values */ /* Suggest possible variable values */
else if (strcasecmp(prev3_wd, "SET") == 0 && else if (pg_strcasecmp(prev3_wd, "SET") == 0 &&
(strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0)) (pg_strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0))
{ {
if (strcasecmp(prev2_wd, "DateStyle") == 0) if (pg_strcasecmp(prev2_wd, "DateStyle") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"ISO", "SQL", "Postgres", "German", {"ISO", "SQL", "Postgres", "German",
@ -1213,7 +1213,7 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(my_list); COMPLETE_WITH_LIST(my_list);
} }
else if (strcasecmp(prev2_wd, "GEQO") == 0) else if (pg_strcasecmp(prev2_wd, "GEQO") == 0)
{ {
static const char * const my_list[] = static const char * const my_list[] =
{"ON", "OFF", "DEFAULT", NULL}; {"ON", "OFF", "DEFAULT", NULL};
@ -1230,23 +1230,23 @@ psql_completion(char *text, int start, int end)
} }
/* START TRANSACTION */ /* START TRANSACTION */
else if (strcasecmp(prev_wd, "START") == 0) else if (pg_strcasecmp(prev_wd, "START") == 0)
COMPLETE_WITH_CONST("TRANSACTION"); COMPLETE_WITH_CONST("TRANSACTION");
/* TRUNCATE */ /* TRUNCATE */
else if (strcasecmp(prev_wd, "TRUNCATE") == 0) else if (pg_strcasecmp(prev_wd, "TRUNCATE") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* UNLISTEN */ /* UNLISTEN */
else if (strcasecmp(prev_wd, "UNLISTEN") == 0) else if (pg_strcasecmp(prev_wd, "UNLISTEN") == 0)
COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(relname) FROM pg_catalog.pg_listener WHERE substring(pg_catalog.quote_ident(relname),1,%d)='%s' UNION SELECT '*'"); COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(relname) FROM pg_catalog.pg_listener WHERE substring(pg_catalog.quote_ident(relname),1,%d)='%s' UNION SELECT '*'");
/* UPDATE */ /* UPDATE */
/* If prev. word is UPDATE suggest a list of tables */ /* If prev. word is UPDATE suggest a list of tables */
else if (strcasecmp(prev_wd, "UPDATE") == 0) else if (pg_strcasecmp(prev_wd, "UPDATE") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* Complete UPDATE <table> with "SET" */ /* Complete UPDATE <table> with "SET" */
else if (strcasecmp(prev2_wd, "UPDATE") == 0) else if (pg_strcasecmp(prev2_wd, "UPDATE") == 0)
COMPLETE_WITH_CONST("SET"); COMPLETE_WITH_CONST("SET");
/* /*
@ -1254,29 +1254,29 @@ psql_completion(char *text, int start, int end)
* _first_ word) the word before it was (hopefully) a table name and * _first_ word) the word before it was (hopefully) a table name and
* we'll now make a list of attributes. * we'll now make a list of attributes.
*/ */
else if (strcasecmp(prev_wd, "SET") == 0) else if (pg_strcasecmp(prev_wd, "SET") == 0)
COMPLETE_WITH_ATTR(prev2_wd); COMPLETE_WITH_ATTR(prev2_wd);
/* VACUUM */ /* VACUUM */
else if (strcasecmp(prev_wd, "VACUUM") == 0) else if (pg_strcasecmp(prev_wd, "VACUUM") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
" UNION SELECT 'FULL'" " UNION SELECT 'FULL'"
" UNION SELECT 'ANALYZE'" " UNION SELECT 'ANALYZE'"
" UNION SELECT 'VERBOSE'"); " UNION SELECT 'VERBOSE'");
else if (strcasecmp(prev2_wd, "VACUUM") == 0 && else if (pg_strcasecmp(prev2_wd, "VACUUM") == 0 &&
(strcasecmp(prev_wd, "FULL") == 0 || (pg_strcasecmp(prev_wd, "FULL") == 0 ||
strcasecmp(prev_wd, "ANALYZE") == 0 || pg_strcasecmp(prev_wd, "ANALYZE") == 0 ||
strcasecmp(prev_wd, "VERBOSE") == 0)) pg_strcasecmp(prev_wd, "VERBOSE") == 0))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* WHERE */ /* WHERE */
/* Simple case of the word before the where being the table name */ /* Simple case of the word before the where being the table name */
else if (strcasecmp(prev_wd, "WHERE") == 0) else if (pg_strcasecmp(prev_wd, "WHERE") == 0)
COMPLETE_WITH_ATTR(prev2_wd); COMPLETE_WITH_ATTR(prev2_wd);
/* ... FROM ... */ /* ... FROM ... */
/* TODO: also include SRF ? */ /* TODO: also include SRF ? */
else if (strcasecmp(prev_wd, "FROM") == 0) else if (pg_strcasecmp(prev_wd, "FROM") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, NULL);
@ -1345,7 +1345,7 @@ psql_completion(char *text, int start, int end)
for (i = 0; words_after_create[i].name; i++) for (i = 0; words_after_create[i].name; i++)
{ {
if (strcasecmp(prev_wd, words_after_create[i].name) == 0) if (pg_strcasecmp(prev_wd, words_after_create[i].name) == 0)
{ {
if (words_after_create[i].query) if (words_after_create[i].query)
COMPLETE_WITH_QUERY(words_after_create[i].query); COMPLETE_WITH_QUERY(words_after_create[i].query);
@ -1415,7 +1415,7 @@ create_command_generator(const char *text, int state)
/* find something that matches */ /* find something that matches */
while ((name = words_after_create[list_index++].name)) while ((name = words_after_create[list_index++].name))
if (strncasecmp(name, text, string_length) == 0) if (pg_strncasecmp(name, text, string_length) == 0)
return pg_strdup(name); return pg_strdup(name);
/* if nothing matches, return NULL */ /* if nothing matches, return NULL */
@ -1616,7 +1616,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
while (list_index < PQntuples(result) && while (list_index < PQntuples(result) &&
(item = PQgetvalue(result, list_index++, 0))) (item = PQgetvalue(result, list_index++, 0)))
if (strncasecmp(text, item, string_length) == 0) if (pg_strncasecmp(text, item, string_length) == 0)
return pg_strdup(item); return pg_strdup(item);
} }
@ -1662,7 +1662,7 @@ complete_from_list(const char *text, int state)
} }
/* Second pass is case insensitive, don't bother counting matches */ /* Second pass is case insensitive, don't bother counting matches */
if (!casesensitive && strncasecmp(text, item, string_length) == 0) if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0)
return pg_strdup(item); return pg_strdup(item);
} }

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/c.h,v 1.163 2004/05/05 21:18:29 tgl Exp $ * $PostgreSQL: pgsql/src/include/c.h,v 1.164 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -720,10 +720,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#define memmove(d, s, c) bcopy(s, d, c) #define memmove(d, s, c) bcopy(s, d, c)
#endif #endif
#ifndef HAVE_UNSETENV
extern void unsetenv(const char *name);
#endif
#ifndef DLLIMPORT #ifndef DLLIMPORT
#define DLLIMPORT /* no special DLL markers on most ports */ #define DLLIMPORT /* no special DLL markers on most ports */
#endif #endif

View File

@ -385,9 +385,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H #undef HAVE_STDLIB_H
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */ /* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP #undef HAVE_STRDUP

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.27 2004/04/30 17:52:07 momjian Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.28 2004/05/07 00:24:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -30,6 +30,12 @@ extern char *get_progname(char *argv0);
/* Portable delay handling */ /* Portable delay handling */
extern void pg_usleep(long microsec); extern void pg_usleep(long microsec);
/* Portable SQL-like case-independent comparisons and conversions */
extern int pg_strcasecmp(const char *s1, const char *s2);
extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
extern unsigned char pg_toupper(unsigned char ch);
extern unsigned char pg_tolower(unsigned char ch);
/* Portable prompt handling */ /* Portable prompt handling */
extern char *simple_prompt(const char *prompt, int maxlen, bool echo); extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
@ -130,10 +136,6 @@ extern double rint(double x);
extern int inet_aton(const char *cp, struct in_addr * addr); extern int inet_aton(const char *cp, struct in_addr * addr);
#endif #endif
#ifndef HAVE_STRCASECMP
extern int strcasecmp(char *s1, char *s2);
#endif
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
extern char *strdup(char const *); extern char *strdup(char const *);
#endif #endif
@ -142,6 +144,10 @@ extern char *strdup(char const *);
extern long random(void); extern long random(void);
#endif #endif
#ifndef HAVE_UNSETENV
extern void unsetenv(const char *name);
#endif
#ifndef HAVE_SRANDOM #ifndef HAVE_SRANDOM
extern void srandom(unsigned int seed); extern void srandom(unsigned int seed);
#endif #endif

View File

@ -7,8 +7,6 @@
#undef HAVE_GETRUSAGE #undef HAVE_GETRUSAGE
#define strncasecmp strnicmp
typedef u_short ushort; typedef u_short ushort;
extern int isnan(double dsrc); extern int isnan(double dsrc);

View File

@ -26,9 +26,6 @@
#include <sys/types.h> /* Declare various types, e.g. size_t, #include <sys/types.h> /* Declare various types, e.g. size_t,
* fd_set */ * fd_set */
extern int strcasecmp(const char *, const char *);
extern void bzero(void *, size_t);
extern int fp_class_d(double); extern int fp_class_d(double);
extern long random(void); extern long random(void);

View File

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.3 2003/11/29 22:41:10 pgsql Exp $ * $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.4 2004/05/07 00:24:58 tgl Exp $
*/ */
/* headers if any */ /* headers if any */
@ -59,10 +59,10 @@ typedef int celt; /* type to hold chr, MCCE number, or
#define CHR_MAX 0xfffffffe /* CHR_MAX-CHR_MIN+1 should fit in uchr */ #define CHR_MAX 0xfffffffe /* CHR_MAX-CHR_MIN+1 should fit in uchr */
/* functions operating on chr */ /* functions operating on chr */
#define iscalnum(x) pg_isalnum(x) #define iscalnum(x) pg_wc_isalnum(x)
#define iscalpha(x) pg_isalpha(x) #define iscalpha(x) pg_wc_isalpha(x)
#define iscdigit(x) pg_isdigit(x) #define iscdigit(x) pg_wc_isdigit(x)
#define iscspace(x) pg_isspace(x) #define iscspace(x) pg_wc_isspace(x)
/* and pick up the standard header */ /* and pick up the standard header */
#include "regex.h" #include "regex.h"

View File

@ -495,7 +495,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
/* convert the whole string to lower case */ /* convert the whole string to lower case */
for (i = 0; str_copy[i]; i++) for (i = 0; str_copy[i]; i++)
str_copy[i] = (char) tolower((unsigned char) str_copy[i]); str_copy[i] = (char) pg_tolower((unsigned char) str_copy[i]);
} }
/* look for numerical tokens */ /* look for numerical tokens */
@ -565,7 +565,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
{ {
for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++) for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++)
{ {
month_lower_tmp[j] = (char) tolower((unsigned char) list[i][j]); month_lower_tmp[j] = (char) pg_tolower((unsigned char) list[i][j]);
if (!month_lower_tmp[j]) if (!month_lower_tmp[j])
{ {
/* properly terminated */ /* properly terminated */

View File

@ -1847,7 +1847,7 @@ ParseDateTime(char *timestr, char *lowstr,
{ {
ftype[nf] = DTK_DATE; ftype[nf] = DTK_DATE;
while (isalnum((unsigned char) *(*endstr)) || (*(*endstr) == *dp)) while (isalnum((unsigned char) *(*endstr)) || (*(*endstr) == *dp))
*lp++ = tolower((unsigned char) *(*endstr)++); *lp++ = pg_tolower((unsigned char) *(*endstr)++);
} }
} }
@ -1875,9 +1875,9 @@ ParseDateTime(char *timestr, char *lowstr,
else if (isalpha((unsigned char) *(*endstr))) else if (isalpha((unsigned char) *(*endstr)))
{ {
ftype[nf] = DTK_STRING; ftype[nf] = DTK_STRING;
*lp++ = tolower((unsigned char) *(*endstr)++); *lp++ = pg_tolower((unsigned char) *(*endstr)++);
while (isalpha((unsigned char) *(*endstr))) while (isalpha((unsigned char) *(*endstr)))
*lp++ = tolower((unsigned char) *(*endstr)++); *lp++ = pg_tolower((unsigned char) *(*endstr)++);
/* /*
* Full date string with leading text month? Could also be a * Full date string with leading text month? Could also be a
@ -1919,9 +1919,9 @@ ParseDateTime(char *timestr, char *lowstr,
else if (isalpha((unsigned char) *(*endstr))) else if (isalpha((unsigned char) *(*endstr)))
{ {
ftype[nf] = DTK_SPECIAL; ftype[nf] = DTK_SPECIAL;
*lp++ = tolower((unsigned char) *(*endstr)++); *lp++ = pg_tolower((unsigned char) *(*endstr)++);
while (isalpha((unsigned char) *(*endstr))) while (isalpha((unsigned char) *(*endstr)))
*lp++ = tolower((unsigned char) *(*endstr)++); *lp++ = pg_tolower((unsigned char) *(*endstr)++);
} }
/* otherwise something wrong... */ /* otherwise something wrong... */
else else
@ -3115,7 +3115,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d,
*/ */
for (j = 0; !err && j < szdatetktbl; j++) for (j = 0; !err && j < szdatetktbl; j++)
{ {
if (strcasecmp(datetktbl[j].token, scan_val.str_val) == 0) if (pg_strcasecmp(datetktbl[j].token, scan_val.str_val) == 0)
{ {
/* /*
* tz calculates the offset for the seconds, the * tz calculates the offset for the seconds, the

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.279 2004/05/05 15:03:04 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.280 2004/05/07 00:24:59 tgl Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
@ -609,7 +609,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
/* Informix also has a CLOSE DATABASE command that /* Informix also has a CLOSE DATABASE command that
essantially works like a DISCONNECT CURRENT essantially works like a DISCONNECT CURRENT
as far as I know. */ as far as I know. */
if (strcasecmp($1+strlen("close "), "database") == 0) if (pg_strcasecmp($1+strlen("close "), "database") == 0)
{ {
if (connection) if (connection)
mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement.\n"); mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement.\n");

View File

@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.103 2004/04/25 20:57:32 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.104 2004/05/07 00:24:59 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -24,7 +24,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \ fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
dllist.o md5.o ip.o wchar.o encnames.o \ dllist.o md5.o ip.o wchar.o encnames.o \
$(filter crypt.o getaddrinfo.o inet_aton.o noblock.o snprintf.o strerror.o open.o path.o thread.o, $(LIBOBJS)) $(filter crypt.o getaddrinfo.o inet_aton.o noblock.o pgstrcasecmp.o snprintf.o strerror.o open.o path.o thread.o, $(LIBOBJS))
ifeq ($(PORTNAME), win32) ifeq ($(PORTNAME), win32)
OBJS+=win32.o OBJS+=win32.o
endif endif
@ -53,7 +53,7 @@ backend_src = $(top_srcdir)/src/backend
# For port modules, this only happens if configure decides the module # For port modules, this only happens if configure decides the module
# is needed (see filter hack in OBJS, above). # is needed (see filter hack in OBJS, above).
crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c open.c path.c thread.c: % : $(top_srcdir)/src/port/% crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c thread.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
md5.c ip.c: % : $(backend_src)/libpq/% md5.c ip.c: % : $(backend_src)/libpq/%
@ -79,4 +79,4 @@ uninstall: uninstall-lib
rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
clean distclean maintainer-clean: clean-lib clean distclean maintainer-clean: clean-lib
rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c open.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.158 2004/03/14 22:00:54 tgl Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.159 2004/05/07 00:24:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1904,8 +1904,7 @@ PQfnumber(const PGresult *res, const char *field_name)
} }
else else
{ {
if (isupper((unsigned char) c)) c = pg_tolower((unsigned char) c);
c = tolower((unsigned char) c);
*optr++ = c; *optr++ = c;
} }
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.10 2004/03/05 01:53:59 tgl Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.11 2004/05/07 00:24:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -117,7 +117,7 @@ pqSetenvPoll(PGconn *conn)
if ((val = getenv(conn->next_eo->envName))) if ((val = getenv(conn->next_eo->envName)))
{ {
if (strcasecmp(val, "default") == 0) if (pg_strcasecmp(val, "default") == 0)
sprintf(setQuery, "SET %s = DEFAULT", sprintf(setQuery, "SET %s = DEFAULT",
conn->next_eo->pgName); conn->next_eo->pgName);
else else

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.12 2004/03/21 22:29:11 tgl Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.13 2004/05/07 00:24:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1471,7 +1471,7 @@ build_startup_packet(const PGconn *conn, char *packet,
if ((val = getenv(next_eo->envName)) != NULL) if ((val = getenv(next_eo->envName)) != NULL)
{ {
if (strcasecmp(val, "default") != 0) if (pg_strcasecmp(val, "default") != 0)
{ {
if (packet) if (packet)
strcpy(packet + packet_len, next_eo->pgName); strcpy(packet + packet_len, next_eo->pgName);

View File

@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.39 2004/03/27 03:08:42 tgl Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.40 2004/05/07 00:24:59 tgl Exp $
* *
* NOTES * NOTES
* The client *requires* a valid server certificate. Since * The client *requires* a valid server certificate. Since
@ -544,7 +544,7 @@ verify_peer(PGconn *conn)
*/ */
for (s = h->h_aliases; *s != NULL; s++) for (s = h->h_aliases; *s != NULL; s++)
{ {
if (strcasecmp(conn->peer_cn, *s) == 0) if (pg_strcasecmp(conn->peer_cn, *s) == 0)
return 0; return 0;
} }

View File

@ -2,18 +2,11 @@
#define __win32_h_included #define __win32_h_included
/* /*
* strcasecmp() is not in Windows, stricmp is, though * Some compatibility functions
*/
#define strcasecmp(a,b) stricmp(a,b)
#define strncasecmp(a,b,c) _strnicmp(a,b,c)
/*
* Some other compat functions
*/ */
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#define _timeb timeb #define _timeb timeb
#define _ftime(a) ftime(a) #define _ftime(a) ftime(a)
#define _strnicmp(a,b,c) strnicmp(a,b,c)
#define _errno errno #define _errno errno
#else #else
/* open provided elsewhere */ /* open provided elsewhere */

View File

@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.46 2004/04/01 21:28:46 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.47 2004/05/07 00:24:59 tgl Exp $
* *
********************************************************************* *********************************************************************
*/ */
@ -443,9 +443,9 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
elog(ERROR, "expected trigger to return None or a String"); elog(ERROR, "expected trigger to return None or a String");
srv = PyString_AsString(plrv); srv = PyString_AsString(plrv);
if (strcasecmp(srv, "SKIP") == 0) if (pg_strcasecmp(srv, "SKIP") == 0)
rv = NULL; rv = NULL;
else if (strcasecmp(srv, "MODIFY") == 0) else if (pg_strcasecmp(srv, "MODIFY") == 0)
{ {
TriggerData *tdata = (TriggerData *) fcinfo->context; TriggerData *tdata = (TriggerData *) fcinfo->context;
@ -455,7 +455,7 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
else else
elog(WARNING, "ignoring modified tuple in DELETE trigger"); elog(WARNING, "ignoring modified tuple in DELETE trigger");
} }
else if (strcasecmp(srv, "OK")) else if (pg_strcasecmp(srv, "OK") != 0)
{ {
/* /*
* hmmm, perhaps they only read the pltcl page, not a * hmmm, perhaps they only read the pltcl page, not a

125
src/port/pgstrcasecmp.c Normal file
View File

@ -0,0 +1,125 @@
/*-------------------------------------------------------------------------
*
* pgstrcasecmp.c
* Portable SQL-like case-independent comparisons and conversions.
*
* SQL99 specifies Unicode-aware case normalization, which we don't yet
* have the infrastructure for. Instead we use tolower() to provide a
* locale-aware translation. However, there are some locales where this
* is not right either (eg, Turkish may do strange things with 'i' and
* 'I'). Our current compromise is to use tolower() for characters with
* the high bit set, and use an ASCII-only downcasing for 7-bit
* characters.
*
* NB: this code should match downcase_truncate_identifier() in scansup.c.
*
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/port/pgstrcasecmp.c,v 1.1 2004/05/07 00:24:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <ctype.h>
/*
* Case-independent comparison of two null-terminated strings.
*/
int
pg_strcasecmp(const char *s1, const char *s2)
{
for (;;)
{
unsigned char ch1 = (unsigned char) *s1++;
unsigned char ch2 = (unsigned char) *s2++;
if (ch1 != ch2)
{
if (ch1 >= 'A' && ch1 <= 'Z')
ch1 += 'a' - 'A';
else if (ch1 >= 0x80 && isupper(ch1))
ch1 = tolower(ch1);
if (ch2 >= 'A' && ch2 <= 'Z')
ch2 += 'a' - 'A';
else if (ch2 >= 0x80 && isupper(ch2))
ch2 = tolower(ch2);
if (ch1 != ch2)
return (int) ch1 - (int) ch2;
}
if (ch1 == 0)
break;
}
return 0;
}
/*
* Case-independent comparison of two not-necessarily-null-terminated strings.
* At most n bytes will be examined from each string.
*/
int
pg_strncasecmp(const char *s1, const char *s2, size_t n)
{
while (n-- > 0)
{
unsigned char ch1 = (unsigned char) *s1++;
unsigned char ch2 = (unsigned char) *s2++;
if (ch1 != ch2)
{
if (ch1 >= 'A' && ch1 <= 'Z')
ch1 += 'a' - 'A';
else if (ch1 >= 0x80 && isupper(ch1))
ch1 = tolower(ch1);
if (ch2 >= 'A' && ch2 <= 'Z')
ch2 += 'a' - 'A';
else if (ch2 >= 0x80 && isupper(ch2))
ch2 = tolower(ch2);
if (ch1 != ch2)
return (int) ch1 - (int) ch2;
}
if (ch1 == 0)
break;
}
return 0;
}
/*
* Fold a character to upper case.
*
* Unlike some versions of toupper(), this is safe to apply to characters
* that aren't upper case letters. Note however that the whole thing is
* a bit bogus for multibyte character sets.
*/
unsigned char
pg_toupper(unsigned char ch)
{
if (ch >= 'a' && ch <= 'z')
ch += 'A' - 'a';
else if (ch >= 0x80 && islower(ch))
ch = toupper(ch);
return ch;
}
/*
* Fold a character to lower case.
*
* Unlike some versions of tolower(), this is safe to apply to characters
* that aren't lower case letters. Note however that the whole thing is
* a bit bogus for multibyte character sets.
*/
unsigned char
pg_tolower(unsigned char ch)
{
if (ch >= 'A' && ch <= 'Z')
ch += 'a' - 'A';
else if (ch >= 0x80 && isupper(ch))
ch = tolower(ch);
return ch;
}

View File

@ -1,74 +0,0 @@
/* $PostgreSQL: pgsql/src/port/strcasecmp.c,v 1.4 2003/11/29 22:41:31 pgsql Exp $ */
/*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific written prior permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#include <sys/types.h>
#include <string.h>
/*
* This array is designed for mapping upper and lower case letter
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
static unsigned char charmap[] = {
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
};
int
strcasecmp(char *s1, char *s2)
{
unsigned char u1,
u2;
for (;;)
{
u1 = (unsigned char) *s1++;
u2 = (unsigned char) *s2++;
if (charmap[u1] != charmap[u2])
return charmap[u1] - charmap[u2];
if (u1 == '\0')
return 0;
}
}