mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix the setlocale problem in a way that actually works. setlocale
returns a string corresponding to the new setting, not the old, therefore the previous patch was quite wrong.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.24 2001/09/25 18:37:17 meskes Exp $ */
 | 
					/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.25 2001/09/29 20:12:07 tgl Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * The aim is to get a simpler inteface to the database routines.
 | 
					 * The aim is to get a simpler inteface to the database routines.
 | 
				
			||||||
@@ -1006,23 +1006,26 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
 | 
				
			|||||||
	va_list		args;
 | 
						va_list		args;
 | 
				
			||||||
	struct statement *stmt;
 | 
						struct statement *stmt;
 | 
				
			||||||
	struct connection *con = get_connection(connection_name);
 | 
						struct connection *con = get_connection(connection_name);
 | 
				
			||||||
	bool		status = true;
 | 
						bool		status;
 | 
				
			||||||
	char	   	*locale;
 | 
						char	   	*oldlocale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Make sure we do NOT honor the locale for numeric input/output */
 | 
						/* Make sure we do NOT honor the locale for numeric input/output */
 | 
				
			||||||
	/* since the database wants the standard decimal point */
 | 
						/* since the database wants the standard decimal point */
 | 
				
			||||||
	locale = setlocale(LC_NUMERIC, "C");
 | 
						oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
 | 
				
			||||||
 | 
						setlocale(LC_NUMERIC, "C");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ecpg_init(con, connection_name, lineno))
 | 
						if (!ecpg_init(con, connection_name, lineno))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		setlocale(LC_NUMERIC, locale);
 | 
							setlocale(LC_NUMERIC, oldlocale);
 | 
				
			||||||
 | 
							free(oldlocale);
 | 
				
			||||||
		return (false);
 | 
							return (false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_start(args, query);
 | 
						va_start(args, query);
 | 
				
			||||||
	if (create_statement(lineno, con, &stmt, query, args) == false)
 | 
						if (create_statement(lineno, con, &stmt, query, args) == false)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		setlocale(LC_NUMERIC, locale);
 | 
							setlocale(LC_NUMERIC, oldlocale);
 | 
				
			||||||
 | 
							free(oldlocale);
 | 
				
			||||||
		return (false);
 | 
							return (false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	va_end(args);
 | 
						va_end(args);
 | 
				
			||||||
@@ -1033,7 +1036,8 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
 | 
				
			|||||||
		free_statement(stmt);
 | 
							free_statement(stmt);
 | 
				
			||||||
		ECPGlog("ECPGdo: not connected to %s\n", con->name);
 | 
							ECPGlog("ECPGdo: not connected to %s\n", con->name);
 | 
				
			||||||
		ECPGraise(lineno, ECPG_NOT_CONN, NULL);
 | 
							ECPGraise(lineno, ECPG_NOT_CONN, NULL);
 | 
				
			||||||
		setlocale(LC_NUMERIC, locale);
 | 
							setlocale(LC_NUMERIC, oldlocale);
 | 
				
			||||||
 | 
							free(oldlocale);
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1041,7 +1045,9 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
 | 
				
			|||||||
	free_statement(stmt);
 | 
						free_statement(stmt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* and reset locale value so our application is not affected */
 | 
						/* and reset locale value so our application is not affected */
 | 
				
			||||||
	setlocale(LC_NUMERIC, locale);
 | 
						setlocale(LC_NUMERIC, oldlocale);
 | 
				
			||||||
 | 
						free(oldlocale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (status);
 | 
						return (status);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user