if (status == PSQL_CMD_UNKNOWN)
{
if (pset.cur_cmd_interactive)
- fprintf(stderr, _("Invalid command \\%s. Try \\? for help.\n"), cmd);
+ psql_error("Invalid command \\%s. Try \\? for help.\n", cmd);
else
psql_error("invalid command \\%s\n", cmd);
status = PSQL_CMD_ERROR;
if (strcmp(pw1, pw2) != 0)
{
- fprintf(stderr, _("Passwords didn't match.\n"));
+ psql_error("Passwords didn't match.\n");
success = false;
}
else
if (!encrypted_password)
{
- fprintf(stderr, _("Password encryption failed.\n"));
+ psql_error("Password encryption failed.\n");
success = false;
}
else
while ((value = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true)))
{
- fprintf(stderr, "+ opt(%d) = |%s|\n", i++, value);
+ psql_error("+ opt(%d) = |%s|\n", i++, value);
free(value);
}
}
* to connect to the wrong database by using defaults, so require
* all parameters to be specified.
*/
- fputs(_("All connection parameters must be supplied because no database connection exists\n"), stderr);
+ psql_error("All connection parameters must be supplied because no "
+ "database connection exists\n");
return false;
}
/* pset.db is left unmodified */
if (o_conn)
- fputs(_("Previous connection kept\n"), stderr);
+ psql_error("Previous connection kept\n");
}
else
{
if (!string)
{
- fprintf(stderr, _("%s: pg_strdup: cannot duplicate null pointer (internal error)\n"),
+ psql_error("%s: pg_strdup: cannot duplicate null pointer (internal error)\n",
pset.progname);
exit(EXIT_FAILURE);
}
va_list ap;
fflush(stdout);
- if (pset.queryFout != stdout)
+ if (pset.queryFout && pset.queryFout != stdout)
fflush(pset.queryFout);
if (pset.inputfile)
static CRITICAL_SECTION cancelConnLock;
#endif
+/* Used from signal handlers, no buffering */
#define write_stderr(str) write(fileno(stderr), str, strlen(str))
exit(EXIT_BADCONN);
}
- fputs(_("The connection to the server was lost. Attempting reset: "), stderr);
+ psql_error("The connection to the server was lost. Attempting reset: ");
PQreset(pset.db);
OK = ConnectionUp();
if (!OK)
{
- fputs(_("Failed.\n"), stderr);
+ psql_error("Failed.\n");
PQfinish(pset.db);
pset.db = NULL;
ResetCancelConn();
UnsyncVariables();
}
else
- fputs(_("Succeeded.\n"), stderr);
+ psql_error("Succeeded.\n");
}
return OK;
{
if (on_error_rollback_warning == false && pset.sversion < 80000)
{
- fprintf(stderr, _("The server (version %d.%d) does not support savepoints for ON_ERROR_ROLLBACK.\n"),
+ psql_error("The server (version %d.%d) does not support savepoints for ON_ERROR_ROLLBACK.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
on_error_rollback_warning = true;
}
if (pset.sversion < 80000)
{
- fprintf(stderr, _("The server (version %d.%d) does not support tablespaces.\n"),
+ psql_error("The server (version %d.%d) does not support tablespaces.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (strlen(functypes) != strspn(functypes, "antwS+"))
{
- fprintf(stderr, _("\\df only takes [antwS+] as options\n"));
+ psql_error("\\df only takes [antwS+] as options\n");
return true;
}
if (showWindow && pset.sversion < 80400)
{
- fprintf(stderr, _("\\df does not take a \"w\" option with server version %d.%d\n"),
+ psql_error("\\df does not take a \"w\" option with server version %d.%d\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 90000)
{
- fprintf(stderr, _("The server (version %d.%d) does not support altering default privileges.\n"),
+ psql_error("The server (version %d.%d) does not support altering default privileges.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (PQntuples(res) == 0)
{
if (!pset.quiet)
- fprintf(stderr, _("Did not find any relation named \"%s\".\n"),
+ psql_error("Did not find any relation named \"%s\".\n",
pattern);
PQclear(res);
return false;
if (PQntuples(res) == 0)
{
if (!pset.quiet)
- fprintf(stderr, _("Did not find any relation with OID %s.\n"),
- oid);
+ psql_error("Did not find any relation with OID %s.\n", oid);
goto error_return;
}
if (pset.sversion < 90100)
{
- fprintf(stderr, _("The server (version %d.%d) does not support collations.\n"),
+ psql_error("The server (version %d.%d) does not support collations.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 80300)
{
- fprintf(stderr, _("The server (version %d.%d) does not support full text search.\n"),
+ psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (PQntuples(res) == 0)
{
if (!pset.quiet)
- fprintf(stderr, _("Did not find any text search parser named \"%s\".\n"),
+ psql_error("Did not find any text search parser named \"%s\".\n",
pattern);
PQclear(res);
return false;
if (pset.sversion < 80300)
{
- fprintf(stderr, _("The server (version %d.%d) does not support full text search.\n"),
+ psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 80300)
{
- fprintf(stderr, _("The server (version %d.%d) does not support full text search.\n"),
+ psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 80300)
{
- fprintf(stderr, _("The server (version %d.%d) does not support full text search.\n"),
+ psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (PQntuples(res) == 0)
{
if (!pset.quiet)
- fprintf(stderr, _("Did not find any text search configuration named \"%s\".\n"),
+ psql_error("Did not find any text search configuration named \"%s\".\n",
pattern);
PQclear(res);
return false;
if (pset.sversion < 80400)
{
- fprintf(stderr, _("The server (version %d.%d) does not support foreign-data wrappers.\n"),
+ psql_error("The server (version %d.%d) does not support foreign-data wrappers.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 80400)
{
- fprintf(stderr, _("The server (version %d.%d) does not support foreign servers.\n"),
+ psql_error("The server (version %d.%d) does not support foreign servers.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 80400)
{
- fprintf(stderr, _("The server (version %d.%d) does not support user mappings.\n"),
+ psql_error("The server (version %d.%d) does not support user mappings.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 90100)
{
- fprintf(stderr, _("The server (version %d.%d) does not support foreign tables.\n"),
+ psql_error("The server (version %d.%d) does not support foreign tables.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 90100)
{
- fprintf(stderr, _("The server (version %d.%d) does not support extensions.\n"),
+ psql_error("The server (version %d.%d) does not support extensions.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (pset.sversion < 90100)
{
- fprintf(stderr, _("The server (version %d.%d) does not support extensions.\n"),
+ psql_error("The server (version %d.%d) does not support extensions.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (!pset.quiet)
{
if (pattern)
- fprintf(stderr, _("Did not find any extension named \"%s\".\n"),
+ psql_error("Did not find any extension named \"%s\".\n",
pattern);
else
- fprintf(stderr, _("Did not find any extensions.\n"));
+ psql_error("Did not find any extensions.\n");
}
PQclear(res);
return false;