static void verbosity_hook(const char *newval) { if (newval == NULL) pset.verbosity = PQERRORS_DEFAULT; else if (strcmp(newval, "default") == 0) pset.verbosity = PQERRORS_DEFAULT; else if (strcmp(newval, "terse") == 0) pset.verbosity = PQERRORS_TERSE; else if (strcmp(newval, "verbose") == 0) pset.verbosity = PQERRORS_VERBOSE; else pset.verbosity = PQERRORS_DEFAULT; if (pset.db) PQsetErrorVerbosity(pset.db, pset.verbosity); }
/* * SyncVariables * * Make psql's internal variables agree with connection state upon * establishing a new connection. */ void SyncVariables(void) { /* get stuff from connection */ pset.encoding = PQclientEncoding(pset.db); pset.popt.topt.encoding = pset.encoding; pset.sversion = PQserverVersion(pset.db); SetVariable(pset.vars, "DBNAME", PQdb(pset.db)); SetVariable(pset.vars, "USER", PQuser(pset.db)); SetVariable(pset.vars, "HOST", PQhost(pset.db)); SetVariable(pset.vars, "PORT", PQport(pset.db)); SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding)); /* send stuff to it, too */ PQsetErrorVerbosity(pset.db, pset.verbosity); }
static void verbosity_hook(const char *newval) { if (newval == NULL) pset.verbosity = PQERRORS_DEFAULT; else if (pg_strcasecmp(newval, "default") == 0) pset.verbosity = PQERRORS_DEFAULT; else if (pg_strcasecmp(newval, "terse") == 0) pset.verbosity = PQERRORS_TERSE; else if (pg_strcasecmp(newval, "verbose") == 0) pset.verbosity = PQERRORS_VERBOSE; else { psql_error("unrecognized value \"%s\" for \"%s\"; assuming \"%s\"\n", newval, "VERBOSITY", "default"); pset.verbosity = PQERRORS_DEFAULT; } if (pset.db) PQsetErrorVerbosity(pset.db, pset.verbosity); }