diff options
Diffstat (limited to 'src/bin/psql')
-rw-r--r-- | src/bin/psql/command.c | 6 | ||||
-rw-r--r-- | src/bin/psql/copy.c | 14 | ||||
-rw-r--r-- | src/bin/psql/create_help.pl | 3 | ||||
-rw-r--r-- | src/bin/psql/describe.c | 46 | ||||
-rw-r--r-- | src/bin/psql/print.c | 6 | ||||
-rw-r--r-- | src/bin/psql/startup.c | 12 | ||||
-rw-r--r-- | src/bin/psql/tab-complete.c | 14 |
7 files changed, 53 insertions, 48 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 0e997940328..351e684132c 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1580,9 +1580,9 @@ do_connect(char *dbname, char *user, char *host, char *port) if (!o_conn && (!dbname || !user || !host || !port)) { /* - * We don't know the supplied connection parameters and don't want - * to connect to the wrong database by using defaults, so require - * all parameters to be specified. + * We don't know the supplied connection parameters and don't want to + * connect to the wrong database by using defaults, so require all + * parameters to be specified. */ psql_error("All connection parameters must be supplied because no " "database connection exists\n"); diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 57cbf928161..b5732c79709 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -35,7 +35,7 @@ * \copy ( select stmt ) to filename [options] * * where 'filename' can be one of the following: - * '<file path>' | PROGRAM '<command>' | stdin | stdout | pstdout | pstdout + * '<file path>' | PROGRAM '<command>' | stdin | stdout | pstdout | pstdout * * An undocumented fact is that you can still write BINARY before the * tablename; this is a hangover from the pre-7.3 syntax. The options @@ -203,7 +203,7 @@ parse_slash_copy(const char *args) if (pg_strcasecmp(token, "program") == 0) { - int toklen; + int toklen; token = strtokx(NULL, whitespace, NULL, "'", 0, false, false, pset.encoding); @@ -211,8 +211,8 @@ parse_slash_copy(const char *args) goto error; /* - * The shell command must be quoted. This isn't fool-proof, but catches - * most quoting errors. + * The shell command must be quoted. This isn't fool-proof, but + * catches most quoting errors. */ toklen = strlen(token); if (token[0] != '\'' || toklen < 2 || token[toklen - 1] != '\'') @@ -381,7 +381,8 @@ do_copy(const char *args) { if (options->program) { - int pclose_rc = pclose(copystream); + int pclose_rc = pclose(copystream); + if (pclose_rc != 0) { if (pclose_rc < 0) @@ -389,7 +390,8 @@ do_copy(const char *args) strerror(errno)); else { - char *reason = wait_result_to_str(pclose_rc); + char *reason = wait_result_to_str(pclose_rc); + psql_error("%s: %s\n", options->file, reason ? reason : ""); if (reason) diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl index be23a23c41c..08fcc489518 100644 --- a/src/bin/psql/create_help.pl +++ b/src/bin/psql/create_help.pl @@ -202,8 +202,7 @@ print HFILE " #define QL_HELP_COUNT " - . scalar(keys %entries) - . " /* number of help items */ + . scalar(keys %entries) . " /* number of help items */ #define QL_MAX_CMD_LEN $maxlen /* largest strlen(cmd) */ diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 4ce831a4335..9b6b9c2cd0a 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -135,7 +135,7 @@ describeTablespaces(const char *pattern, bool verbose) if (pset.sversion < 80000) { psql_error("The server (version %d.%d) does not support tablespaces.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -228,7 +228,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool if (showWindow && pset.sversion < 80400) { psql_error("\\df does not take a \"w\" option with server version %d.%d\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -330,7 +330,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool if (verbose) appendPQExpBuffer(&buf, - ",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\"" + ",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\"" ",\n CASE\n" " WHEN p.provolatile = 'i' THEN '%s'\n" " WHEN p.provolatile = 's' THEN '%s'\n" @@ -807,7 +807,7 @@ listDefaultACLs(const char *pattern) if (pset.sversion < 90000) { psql_error("The server (version %d.%d) does not support altering default privileges.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -1078,7 +1078,7 @@ describeTableDetails(const char *pattern, bool verbose, bool showSystem) { if (!pset.quiet) psql_error("Did not find any relation named \"%s\".\n", - pattern); + pattern); PQclear(res); return false; } @@ -2565,7 +2565,7 @@ listDbRoleSettings(const char *pattern, const char *pattern2) bool havewhere; printfPQExpBuffer(&buf, "SELECT rolname AS \"%s\", datname AS \"%s\",\n" - "pg_catalog.array_to_string(setconfig, E'\\n') AS \"%s\"\n" + "pg_catalog.array_to_string(setconfig, E'\\n') AS \"%s\"\n" "FROM pg_db_role_setting AS s\n" "LEFT JOIN pg_database ON pg_database.oid = setdatabase\n" "LEFT JOIN pg_roles ON pg_roles.oid = setrole\n", @@ -3020,7 +3020,7 @@ listEventTriggers(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; static const bool translate_columns[] = - {false, false, false, true, false, false, false}; + {false, false, false, true, false, false, false}; initPQExpBuffer(&buf); @@ -3034,7 +3034,7 @@ listEventTriggers(const char *pattern, bool verbose) " when 'D' then 'disabled' end as \"%s\", " "e.evtfoid::regproc as \"%s\", " "array_to_string(array(select x " - " from unnest(evttags) as t(x)), ', ') as \"%s\" ", + " from unnest(evttags) as t(x)), ', ') as \"%s\" ", gettext_noop("Name"), gettext_noop("Event"), gettext_noop("Owner"), @@ -3043,7 +3043,7 @@ listEventTriggers(const char *pattern, bool verbose) gettext_noop("Tags")); if (verbose) appendPQExpBuffer(&buf, - ",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"", + ",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"", gettext_noop("Description")); appendPQExpBuffer(&buf, "\nFROM pg_event_trigger e "); @@ -3183,7 +3183,7 @@ listCollations(const char *pattern, bool verbose, bool showSystem) if (pset.sversion < 90100) { psql_error("The server (version %d.%d) does not support collations.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3314,7 +3314,7 @@ listTSParsers(const char *pattern, bool verbose) if (pset.sversion < 80300) { psql_error("The server (version %d.%d) does not support full text search.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3391,7 +3391,7 @@ listTSParsersVerbose(const char *pattern) { if (!pset.quiet) psql_error("Did not find any text search parser named \"%s\".\n", - pattern); + pattern); PQclear(res); return false; } @@ -3547,7 +3547,7 @@ listTSDictionaries(const char *pattern, bool verbose) if (pset.sversion < 80300) { psql_error("The server (version %d.%d) does not support full text search.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3615,7 +3615,7 @@ listTSTemplates(const char *pattern, bool verbose) if (pset.sversion < 80300) { psql_error("The server (version %d.%d) does not support full text search.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3683,7 +3683,7 @@ listTSConfigs(const char *pattern, bool verbose) if (pset.sversion < 80300) { psql_error("The server (version %d.%d) does not support full text search.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3761,7 +3761,7 @@ listTSConfigsVerbose(const char *pattern) { if (!pset.quiet) psql_error("Did not find any text search configuration named \"%s\".\n", - pattern); + pattern); PQclear(res); return false; } @@ -3881,7 +3881,7 @@ listForeignDataWrappers(const char *pattern, bool verbose) if (pset.sversion < 80400) { psql_error("The server (version %d.%d) does not support foreign-data wrappers.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -3961,7 +3961,7 @@ listForeignServers(const char *pattern, bool verbose) if (pset.sversion < 80400) { psql_error("The server (version %d.%d) does not support foreign servers.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -4040,7 +4040,7 @@ listUserMappings(const char *pattern, bool verbose) if (pset.sversion < 80400) { psql_error("The server (version %d.%d) does not support user mappings.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -4098,7 +4098,7 @@ listForeignTables(const char *pattern, bool verbose) if (pset.sversion < 90100) { psql_error("The server (version %d.%d) does not support foreign tables.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -4172,7 +4172,7 @@ listExtensions(const char *pattern) if (pset.sversion < 90100) { psql_error("The server (version %d.%d) does not support extensions.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -4226,7 +4226,7 @@ listExtensionContents(const char *pattern) if (pset.sversion < 90100) { psql_error("The server (version %d.%d) does not support extensions.\n", - pset.sversion / 10000, (pset.sversion / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100); return true; } @@ -4253,7 +4253,7 @@ listExtensionContents(const char *pattern) { if (pattern) psql_error("Did not find any extension named \"%s\".\n", - pattern); + pattern); else psql_error("Did not find any extensions.\n"); } diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 7e1f27ac9e2..5589ceaa7ff 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -1747,10 +1747,10 @@ print_latex_longtable_text(const printTableContent *cont, FILE *fout) { fputs("p{", fout); fwrite(next_opt_table_attr_char, strcspn(next_opt_table_attr_char, - LONGTABLE_WHITESPACE), 1, fout); + LONGTABLE_WHITESPACE), 1, fout); last_opt_table_attr_char = next_opt_table_attr_char; next_opt_table_attr_char += strcspn(next_opt_table_attr_char, - LONGTABLE_WHITESPACE); + LONGTABLE_WHITESPACE); fputs("\\textwidth}", fout); } /* use previous value */ @@ -1758,7 +1758,7 @@ print_latex_longtable_text(const printTableContent *cont, FILE *fout) { fputs("p{", fout); fwrite(last_opt_table_attr_char, strcspn(last_opt_table_attr_char, - LONGTABLE_WHITESPACE), 1, fout); + LONGTABLE_WHITESPACE), 1, fout); fputs("\\textwidth}", fout); } else diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 5d7fe6ea27f..831e1b3ca6f 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -151,9 +151,9 @@ main(int argc, char *argv[]) parse_psql_options(argc, argv, &options); /* - * If no action was specified and we're in non-interactive mode, treat - * it as if the user had specified "-f -". This lets single-transaction - * mode work in this case. + * If no action was specified and we're in non-interactive mode, treat it + * as if the user had specified "-f -". This lets single-transaction mode + * work in this case. */ if (options.action == ACT_NOTHING && pset.notty) { @@ -165,9 +165,9 @@ main(int argc, char *argv[]) if (options.single_txn && options.action != ACT_FILE) { if (options.action == ACT_NOTHING) - fprintf(stderr,_("%s: -1 can only be used in non-interactive mode\n"), pset.progname); + fprintf(stderr, _("%s: -1 can only be used in non-interactive mode\n"), pset.progname); else - fprintf(stderr,_("%s: -1 is incompatible with -c and -l\n"), pset.progname); + fprintf(stderr, _("%s: -1 is incompatible with -c and -l\n"), pset.progname); exit(EXIT_FAILURE); } @@ -621,7 +621,7 @@ process_psqlrc(char *argv0) if (envrc != NULL && strlen(envrc) > 0) { /* might need to free() this */ - char *envrc_alloc = pstrdup(envrc); + char *envrc_alloc = pstrdup(envrc); expand_tilde(&envrc_alloc); process_psqlrc_file(envrc_alloc); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7d2c8126126..8eb9f83b994 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -360,7 +360,7 @@ static const SchemaQuery Query_for_list_of_constraints_with_schema = { /* selcondition */ "c.conrelid <> 0", /* viscondition */ - "true", /* there is no pg_constraint_is_visible */ + "true", /* there is no pg_constraint_is_visible */ /* namespace */ "c.connamespace", /* result */ @@ -646,7 +646,7 @@ static const SchemaQuery Query_for_list_of_matviews = { " and pg_catalog.pg_type_is_visible(t.oid)" /* the silly-looking length condition is just to eat up the current word */ -#define Query_for_list_of_tables_for_constraint \ +#define Query_for_list_of_tables_for_constraint \ "SELECT pg_catalog.quote_ident(relname) "\ " FROM pg_catalog.pg_class"\ " WHERE (%d = pg_catalog.length('%s'))"\ @@ -1472,7 +1472,11 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev2_wd, "DROP") == 0 && pg_strcasecmp(prev_wd, "COLUMN") == 0) COMPLETE_WITH_ATTR(prev3_wd, ""); - /* If we have ALTER TABLE <sth> DROP|RENAME|VALIDATE CONSTRAINT, provide list of constraints */ + + /* + * If we have ALTER TABLE <sth> DROP|RENAME|VALIDATE CONSTRAINT, provide + * list of constraints + */ else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 && pg_strcasecmp(prev4_wd, "TABLE") == 0 && (pg_strcasecmp(prev2_wd, "DROP") == 0 || @@ -1832,7 +1836,7 @@ psql_completion(char *text, int start, int end) * If we have CLUSTER VERBOSE <sth> USING, then add the index as well. */ else if (pg_strcasecmp(prev4_wd, "CLUSTER") == 0 && - pg_strcasecmp(prev3_wd, "VERBOSE") == 0 && + pg_strcasecmp(prev3_wd, "VERBOSE") == 0 && pg_strcasecmp(prev_wd, "USING") == 0) { completion_info_charp = prev2_wd; @@ -2934,7 +2938,7 @@ psql_completion(char *text, int start, int end) static const char *const list_SECURITY_LABEL[] = {"LANGUAGE", "SCHEMA", "SEQUENCE", "TABLE", "TYPE", "VIEW", "MATERIALIZED VIEW", "COLUMN", "AGGREGATE", "FUNCTION", "DOMAIN", - "LARGE OBJECT", NULL}; + "LARGE OBJECT", NULL}; COMPLETE_WITH_LIST(list_SECURITY_LABEL); } |