*** ./src/backend/parser/scan.l.orig	2004-01-31 22:38:45.000000000 +0200
--- ./src/backend/parser/scan.l	2004-02-01 03:13:01.000000000 +0200
***************
*** 27,32 ****
--- 27,33 ----
  /* Not needed now that this file is compiled as part of gram.y */
  /* #include "parser/parse.h" */
  #include "utils/builtins.h"
+ #include "utils/pg_locale.h"
  #include "mb/pg_wchar.h"
  
  /* No reason to constrain amount of data slurped */
***************
*** 71,76 ****
--- 72,79 ----
  
  unsigned char unescape_single_char(unsigned char c);
  
+ static int isturkishlocale = -1; /* not initialized */
+ 
  %}
  
  %option 8bit
***************
*** 550,560 ****
  					 * which seems appropriate under standard SQL rules, whereas
  					 * the keyword comparison was NOT locale-dependent.
  					 */
  					ident = pstrdup(yytext);
  					for (i = 0; ident[i]; i++)
  					{
  						if (isupper((unsigned char) ident[i]))
! 							ident[i] = tolower((unsigned char) ident[i]);
  					}
  					if (i >= NAMEDATALEN)
                      {
--- 553,576 ----
  					 * which seems appropriate under standard SQL rules, whereas
  					 * the keyword comparison was NOT locale-dependent.
  					 */
+ 					if (isturkishlocale == -1)
+ 					{
+ 						char *buf;
+ 						buf = (char *)get_locale_category((const char*)NULL);
+ 						isturkishlocale = 0;
+ 						if (buf != NULL && strlen(buf) > 2 && strncmp(buf,"tr",2) == 0)
+ 							isturkishlocale = 1;
+ 					}
  					ident = pstrdup(yytext);
  					for (i = 0; ident[i]; i++)
  					{
  						if (isupper((unsigned char) ident[i]))
! 						{
! 							if(ident[i] == 'I' && isturkishlocale == 1)
! 								ident[i] = 'i';
! 							else
! 								ident[i] = tolower((unsigned char) ident[i]);
! 						}
  					}
  					if (i >= NAMEDATALEN)
                      {
*** ./src/backend/utils/adt/pg_locale.c.orig	2004-02-01 00:53:46.000000000 +0200
--- ./src/backend/utils/adt/pg_locale.c	2004-02-01 01:06:51.000000000 +0200
***************
*** 116,121 ****
--- 116,134 ----
  	return locale_xxx_assign(LC_TIME, value, doit, interactive);
  }
  
+ const char *
+ get_locale_category(const char *category)
+ {
+ 	char	   *save;
+ 
+ 	if (category == NULL)
+ 		category == LC_ALL;
+ 	save = setlocale(category, NULL);
+ 	save = pstrdup(save);
+ 
+ 	return save;
+ }
+ 
  
  /*
   * We allow LC_MESSAGES to actually be set globally.
*** ./src/include/utils/pg_locale.h.orig	2004-02-01 02:10:35.000000000 +0200
--- ./src/include/utils/pg_locale.h	2004-02-01 01:06:49.000000000 +0200
***************
*** 27,32 ****
--- 27,35 ----
  					  bool doit, bool interactive);
  extern const char *locale_time_assign(const char *value,
  				   bool doit, bool interactive);
+ extern const char *get_locale_category(const char *category);
+ 
+ 
  
  extern bool lc_collate_is_c(void);
  
