diff options
Diffstat (limited to 'src/backend/utils/misc')
-rw-r--r-- | src/backend/utils/misc/database.c | 73 | ||||
-rw-r--r-- | src/backend/utils/misc/trace.c | 22 |
2 files changed, 53 insertions, 42 deletions
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index 05b32ac62e7..64347f00fee 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.36 2000/03/08 01:46:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.37 2000/04/12 17:16:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,8 +42,8 @@ ExpandDatabasePath(const char *dbpath) const char *cp; int len; - AssertArg(dbpath); - Assert(DataDir); + AssertArg(dbpath); + Assert(DataDir); if (strlen(dbpath) >= MAXPGPATH) return NULL; /* ain't gonna fit nohow */ @@ -55,7 +55,7 @@ ExpandDatabasePath(const char *dbpath) cp = strrchr(dbpath, SEP_CHAR); len = cp - dbpath; strncpy(buf, dbpath, len); - snprintf(&buf[len], MAXPGPATH-len, "%cbase%c%s", + snprintf(&buf[len], MAXPGPATH - len, "%cbase%c%s", SEP_CHAR, SEP_CHAR, (cp + 1)); #else return NULL; @@ -64,7 +64,7 @@ ExpandDatabasePath(const char *dbpath) /* path delimiter somewhere? then has leading environment variable */ else if ((cp = strchr(dbpath, SEP_CHAR)) != NULL) { - const char *envvar; + const char *envvar; len = cp - dbpath; strncpy(buf, dbpath, len); @@ -83,28 +83,33 @@ ExpandDatabasePath(const char *dbpath) DataDir, SEP_CHAR, SEP_CHAR, dbpath); } - /* check for illegal characters in dbpath - * these should really throw an error, shouldn't they? or else all callers - * need to test for NULL */ - for(cp = buf; *cp; cp++) - { - /* The following characters will not be allowed anywhere in the database - path. (Do not include the slash or '.' here.) */ - char illegal_dbpath_chars[] = - "\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" - "'`"; - - const char *cx; - for (cx = illegal_dbpath_chars; *cx; cx++) - if (*cp == *cx) - return NULL; - /* don't allow access to parent dirs */ - if (strncmp(cp, "/../", 4) == 0 ) - return NULL ; - } + /* + * check for illegal characters in dbpath these should really throw an + * error, shouldn't they? or else all callers need to test for NULL + */ + for (cp = buf; *cp; cp++) + { + + /* + * The following characters will not be allowed anywhere in the + * database path. (Do not include the slash or '.' here.) + */ + char illegal_dbpath_chars[] = + "\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" + "'`"; + + const char *cx; + + for (cx = illegal_dbpath_chars; *cx; cx++) + if (*cp == *cx) + return NULL; + /* don't allow access to parent dirs */ + if (strncmp(cp, "/../", 4) == 0) + return NULL; + } return pstrdup(buf); } /* ExpandDatabasePath() */ @@ -197,18 +202,18 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) * the log relation by hand, too. Instead we take the * conservative assumption that if someone tried to delete it, * it's gone. The other side of the coin is that we might - * accept a tuple that was stored and never committed. All in - * all, this code is pretty shaky. We will cross-check our + * accept a tuple that was stored and never committed. All in + * all, this code is pretty shaky. We will cross-check our * result in ReverifyMyDatabase() in postinit.c. * - * NOTE: if a bogus tuple in pg_database prevents connection - * to a valid database, a fix is to connect to another database - * and do "select * from pg_database". That should cause + * NOTE: if a bogus tuple in pg_database prevents connection to a + * valid database, a fix is to connect to another database and + * do "select * from pg_database". That should cause * committed and dead tuples to be marked with correct states. * * XXX wouldn't it be better to let new backends read the - * database OID from a flat file, handled the same way - * we handle the password relation? + * database OID from a flat file, handled the same way we + * handle the password relation? */ if (TransactionIdIsValid((TransactionId) tup.t_data->t_xmax)) continue; diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index b2ff231d038..69634e1f3f4 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -50,7 +50,8 @@ * Trace option names, must match the constants in trace_opts[]. */ static char *opt_names[] = { - "all", /* 0=trace some, 1=trace all, -1=trace none */ + "all", /* 0=trace some, 1=trace all, -1=trace + * none */ "verbose", "query", "plan", @@ -78,7 +79,7 @@ static char *opt_names[] = { "hostlookup", /* enable hostname lookup in ps_status */ "showportnumber", /* show port number in ps_status */ - /* NUM_PG_OPTIONS */ /* must be the last item of enum */ + /* NUM_PG_OPTIONS *//* must be the last item of enum */ }; /* @@ -95,8 +96,10 @@ tprintf(int flag, const char *fmt,...) { va_list ap; char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1]; + #ifdef USE_SYSLOG int log_level; + #endif if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0)) @@ -161,6 +164,7 @@ tprintf1(const char *fmt,...) return 1; } + #endif /* @@ -212,6 +216,7 @@ write_syslog(int level, char *line) syslog(level, "%s", line); } } + #endif #ifdef ELOG_TIMESTAMPS @@ -222,7 +227,7 @@ char * tprintf_timestamp() { struct timeval tv; - struct timezone tz = { 0, 0 }; + struct timezone tz = {0, 0}; struct tm *time; time_t tm; static char timestamp[32], @@ -236,10 +241,11 @@ tprintf_timestamp() sprintf(timestamp, "%02d%02d%02d.%02d:%02d:%02d.%03d %7s ", time->tm_year % 100, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec, - (int) (tv.tv_usec/1000), pid); + (int) (tv.tv_usec / 1000), pid); return timestamp; } + #endif #ifdef NOT_USED @@ -260,6 +266,7 @@ set_option_flag(int flag, int value) pg_options[flag] = value; return value; } + #endif /* @@ -409,13 +416,12 @@ read_pg_options(SIGNAL_ARGS) void show_options(void) { - int i; + int i; - for (i=0; i<NUM_PG_OPTIONS; i++) { + for (i = 0; i < NUM_PG_OPTIONS; i++) elog(NOTICE, "%s=%d", opt_names[i], pg_options[i]); - } } - + /* * Local variables: * tab-width: 4 |