diff options
author | Tom Lane | 2004-05-07 00:24:59 +0000 |
---|---|---|
committer | Tom Lane | 2004-05-07 00:24:59 +0000 |
commit | 0bd61548ab8d1ac5fee63f48ee9b384502a51ad6 (patch) | |
tree | b0c63b75585d0c396e67a3acd204e226b13eae4b /contrib/pgcrypto/pgcrypto.c | |
parent | 4d46274b33db52618ccf49550213b4d5ce4a7981 (diff) |
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.
Diffstat (limited to 'contrib/pgcrypto/pgcrypto.c')
-rw-r--r-- | contrib/pgcrypto/pgcrypto.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index 6efc044b007..f28f960ad05 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -26,13 +26,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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 <fmgr.h> +#include "postgres.h" + #include <ctype.h> +#include "fmgr.h" +#include "parser/scansup.h" + #include "px.h" #include "px-crypt.h" #include "pgcrypto.h" @@ -554,26 +557,12 @@ find_provider(text *name, char *desc, int silent) { void *res; - char buf[PX_MAX_NAMELEN + 1], - *p; - unsigned len; - unsigned i; + char *buf; int err; - len = VARSIZE(name) - VARHDRSZ; - if (len > PX_MAX_NAMELEN) - { - 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; + buf = downcase_truncate_identifier(VARDATA(name), + VARSIZE(name) - VARHDRSZ, + false); err = provider_lookup(buf, &res); @@ -582,5 +571,7 @@ find_provider(text *name, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("%s type does not exist: \"%s\"", desc, buf))); + pfree(buf); + return err ? NULL : res; } |