Skip to content

Commit b42e37b

Browse files
author
Thomas G. Lockhart
committed
Change quickdie elog notice to a single message.
Clean up FloatExceptionHandler elog message source code.
1 parent 25e950f commit b42e37b

File tree

2 files changed

+54
-27
lines changed

2 files changed

+54
-27
lines changed

src/backend/tcop/postgres.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.53 1997/11/09 04:47:09 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.54 1997/11/10 15:24:55 thomas Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -728,8 +728,9 @@ pg_eval_dest(char *query_string,/* string to execute */
728728
* handle_warn() is used to catch kill(getpid(),1) which
729729
* occurs when elog(WARN) is called.
730730
*
731-
* quickdie() occurs when signalled by the postmaster, some backend
732-
* has bought the farm we need to stop what we're doing and exit.
731+
* quickdie() occurs when signalled by the postmaster.
732+
* Some backend has bought the farm,
733+
* so we need to stop what we're doing and exit.
733734
*
734735
* die() preforms an orderly cleanup via ExitPostgres()
735736
* --------------------------------
@@ -744,12 +745,12 @@ handle_warn(SIGNAL_ARGS)
744745
static void
745746
quickdie(SIGNAL_ARGS)
746747
{
747-
elog(NOTICE, "Message from PostgreSQL backend: The Postmaster has ");
748-
elog(NOTICE, "informed me that some other backend died abnormally and ");
749-
elog(NOTICE, "possibly corrupted shared memory. I have rolled back ");
750-
elog(NOTICE, "the current transaction and am going to terminate your ");
751-
elog(NOTICE, "database system connection and exit. Please reconnect to");
752-
elog(NOTICE, "the database system and repeat your query.");
748+
elog(NOTICE, "Message from PostgreSQL backend:"
749+
"\n\tThe Postmaster has informed me that some other backend"
750+
" died abnormally and possibly corrupted shared memory."
751+
"\n\tI have rolled back the current transaction and am"
752+
" going to terminate your database system connection and exit."
753+
"\n\tPlease reconnect to the database system and repeat your query.");
753754

754755

755756
/*
@@ -771,8 +772,9 @@ die(SIGNAL_ARGS)
771772
static void
772773
FloatExceptionHandler(SIGNAL_ARGS)
773774
{
774-
elog(WARN, "floating point exception! the last floating point operation eit\
775-
her exceeded legal ranges or was a divide by zero");
775+
elog(WARN, "floating point exception!"
776+
" The last floating point operation either exceeded legal ranges"
777+
" or was a divide by zero");
776778
}
777779

778780

@@ -1339,7 +1341,7 @@ PostgresMain(int argc, char *argv[])
13391341
if (IsUnderPostmaster == false)
13401342
{
13411343
puts("\nPOSTGRES backend interactive interface");
1342-
puts("$Revision: 1.53 $ $Date: 1997/11/09 04:47:09 $");
1344+
puts("$Revision: 1.54 $ $Date: 1997/11/10 15:24:55 $");
13431345
}
13441346

13451347
/* ----------------

src/backend/tcop/variable.c

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Routines for handling of 'SET var TO',
33
* 'SHOW var' and 'RESET var' statements.
44
*
5-
* $Id: variable.c,v 1.19 1997/11/07 06:43:16 thomas Exp $
5+
* $Id: variable.c,v 1.20 1997/11/10 15:24:56 thomas Exp $
66
*
77
*/
88

@@ -431,8 +431,13 @@ reset_date()
431431
return TRUE;
432432
}
433433

434+
/* Timezone support
435+
* Working storage for strings is allocated with an arbitrary size of 64 bytes.
436+
*/
437+
434438
static char *defaultTZ = NULL;
435-
static char TZvalue[10];
439+
static char TZvalue[64];
440+
static char tzbuf[64];
436441

437442
bool
438443
parse_timezone(const char *value)
@@ -447,20 +452,30 @@ parse_timezone(const char *value)
447452

448453
while ((value = get_token(&tok, NULL, value)) != 0)
449454
{
450-
if ((defaultTZ == NULL) && (getenv("TZ") != NULL))
455+
/* Not yet tried to save original value from environment? */
456+
if (defaultTZ == NULL)
451457
{
452-
defaultTZ = getenv("TZ");
453-
if (defaultTZ == NULL)
458+
/* found something? then save it for later */
459+
if (getenv("TZ") != NULL)
454460
{
455-
defaultTZ = (char *) -1;
461+
defaultTZ = getenv("TZ");
462+
if (defaultTZ == NULL)
463+
defaultTZ = (char *) -1;
464+
else
465+
strcpy(TZvalue, defaultTZ);
456466
}
467+
/* found nothing so mark with an invalid pointer */
457468
else
458469
{
459-
strcpy(TZvalue, defaultTZ);
470+
defaultTZ = (char *) -1;
460471
}
461472
}
462473

463-
setenv("TZ", tok, TRUE);
474+
strcpy(tzbuf, "TZ=");
475+
strcat(tzbuf, tok);
476+
if (putenv(tzbuf) != 0)
477+
elog(WARN, "Unable to set TZ environment variable to %s", tok);
478+
464479
tzset();
465480
PFREE(tok);
466481
}
@@ -471,29 +486,39 @@ parse_timezone(const char *value)
471486
bool
472487
show_timezone()
473488
{
474-
char buf[64];
475489
char *tz;
476490

477491
tz = getenv("TZ");
478492

479-
strcpy(buf, "Time zone is ");
480-
strcat(buf, ((tz != NULL)? tz: "unknown"));
481-
482-
elog(NOTICE, buf, NULL);
493+
elog(NOTICE, "Time zone is %s", ((tz != NULL)? tz: "unknown"));
483494

484495
return TRUE;
485496
} /* show_timezone() */
486497

498+
/* reset_timezone()
499+
* Set TZ environment variable to original value.
500+
* Note that if TZ was originally not set, TZ should be cleared.
501+
* unsetenv() works fine, but is BSD, not POSIX, and is not available
502+
* under Solaris, among others. Apparently putenv() called as below
503+
* clears the process-specific environment variables.
504+
* Other reasonable arguments to putenv() (e.g. "TZ=", "TZ", "") result
505+
* in a core dump (under Linux anyway).
506+
*/
487507
bool
488508
reset_timezone()
489509
{
490510
if ((defaultTZ != NULL) && (defaultTZ != (char *) -1))
491511
{
492-
setenv("TZ", TZvalue, TRUE);
512+
strcpy(tzbuf, "TZ=");
513+
strcat(tzbuf, TZvalue);
514+
if (putenv(tzbuf) != 0)
515+
elog(WARN, "Unable to set TZ environment variable to %s", TZvalue);
493516
}
494517
else
495518
{
496-
unsetenv("TZ");
519+
strcpy(tzbuf, "=");
520+
if (putenv(tzbuf) != 0)
521+
elog(WARN, "Unable to clear TZ environment variable", NULL);
497522
}
498523
tzset();
499524

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy