mirror of
https://github.com/postgres/postgres.git
synced 2025-12-09 02:08:45 +03:00
Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
This commit is contained in:
@@ -777,7 +777,7 @@ exec_command(const char *cmd,
|
||||
|
||||
/* \i and \ir include files */
|
||||
else if (strcmp(cmd, "i") == 0 || strcmp(cmd, "include") == 0
|
||||
|| strcmp(cmd, "ir") == 0 || strcmp(cmd, "include_relative") == 0)
|
||||
|| strcmp(cmd, "ir") == 0 || strcmp(cmd, "include_relative") == 0)
|
||||
{
|
||||
char *fname = psql_scan_slash_option(scan_state,
|
||||
OT_NORMAL, NULL, true);
|
||||
@@ -789,7 +789,7 @@ exec_command(const char *cmd,
|
||||
}
|
||||
else
|
||||
{
|
||||
bool include_relative;
|
||||
bool include_relative;
|
||||
|
||||
include_relative = (strcmp(cmd, "ir") == 0
|
||||
|| strcmp(cmd, "include_relative") == 0);
|
||||
@@ -1103,16 +1103,16 @@ exec_command(const char *cmd,
|
||||
else if (strcmp(cmd, "setenv") == 0)
|
||||
{
|
||||
char *envvar = psql_scan_slash_option(scan_state,
|
||||
OT_NORMAL, NULL, false);
|
||||
OT_NORMAL, NULL, false);
|
||||
char *envval = psql_scan_slash_option(scan_state,
|
||||
OT_NORMAL, NULL, false);
|
||||
OT_NORMAL, NULL, false);
|
||||
|
||||
if (!envvar)
|
||||
{
|
||||
psql_error("\\%s: missing required argument\n", cmd);
|
||||
success = false;
|
||||
}
|
||||
else if (strchr(envvar,'=') != NULL)
|
||||
else if (strchr(envvar, '=') != NULL)
|
||||
{
|
||||
psql_error("\\%s: environment variable name must not contain \"=\"\n",
|
||||
cmd);
|
||||
@@ -1127,16 +1127,17 @@ exec_command(const char *cmd,
|
||||
else
|
||||
{
|
||||
/* Set variable to the value of the next argument */
|
||||
int len = strlen(envvar) + strlen(envval) + 1;
|
||||
int len = strlen(envvar) + strlen(envval) + 1;
|
||||
char *newval = pg_malloc(len + 1);
|
||||
|
||||
snprintf(newval, len+1, "%s=%s", envvar, envval);
|
||||
snprintf(newval, len + 1, "%s=%s", envvar, envval);
|
||||
putenv(newval);
|
||||
success = true;
|
||||
|
||||
/*
|
||||
* Do not free newval here, it will screw up the environment
|
||||
* if you do. See putenv man page for details. That means we
|
||||
* leak a bit of memory here, but not enough to worry about.
|
||||
* Do not free newval here, it will screw up the environment if
|
||||
* you do. See putenv man page for details. That means we leak a
|
||||
* bit of memory here, but not enough to worry about.
|
||||
*/
|
||||
}
|
||||
free(envvar);
|
||||
@@ -2046,9 +2047,9 @@ process_file(char *filename, bool single_txn, bool use_relative_path)
|
||||
|
||||
/*
|
||||
* If we were asked to resolve the pathname relative to the location
|
||||
* of the currently executing script, and there is one, and this is
|
||||
* a relative pathname, then prepend all but the last pathname
|
||||
* component of the current script to this pathname.
|
||||
* of the currently executing script, and there is one, and this is a
|
||||
* relative pathname, then prepend all but the last pathname component
|
||||
* of the current script to this pathname.
|
||||
*/
|
||||
if (use_relative_path && pset.inputfile && !is_absolute_path(filename)
|
||||
&& !has_drive_prefix(filename))
|
||||
|
||||
@@ -707,7 +707,7 @@ ProcessResult(PGresult **results)
|
||||
|
||||
/*
|
||||
* Call PQgetResult() once more. In the typical case of a
|
||||
* single-command string, it will return NULL. Otherwise, we'll
|
||||
* single-command string, it will return NULL. Otherwise, we'll
|
||||
* have other results to process that may include other COPYs.
|
||||
*/
|
||||
PQclear(*results);
|
||||
@@ -982,11 +982,12 @@ SendQuery(const char *query)
|
||||
break;
|
||||
|
||||
case PQTRANS_INTRANS:
|
||||
|
||||
/*
|
||||
* Do nothing if they are messing with savepoints themselves:
|
||||
* If the user did RELEASE or ROLLBACK, our savepoint is
|
||||
* gone. If they issued a SAVEPOINT, releasing ours would
|
||||
* remove theirs.
|
||||
* If the user did RELEASE or ROLLBACK, our savepoint is gone.
|
||||
* If they issued a SAVEPOINT, releasing ours would remove
|
||||
* theirs.
|
||||
*/
|
||||
if (results &&
|
||||
(strcmp(PQcmdStatus(results), "SAVEPOINT") == 0 ||
|
||||
|
||||
@@ -394,7 +394,7 @@ handleCopyOut(PGconn *conn, FILE *copystream)
|
||||
/*
|
||||
* Check command status and return to normal libpq state. After a
|
||||
* client-side error, the server will remain ready to deliver data. The
|
||||
* cleanest thing is to fully drain and discard that data. If the
|
||||
* cleanest thing is to fully drain and discard that data. If the
|
||||
* client-side error happened early in a large file, this takes a long
|
||||
* time. Instead, take advantage of the fact that PQexec() will silently
|
||||
* end any ongoing PGRES_COPY_OUT state. This does cause us to lose the
|
||||
@@ -405,7 +405,7 @@ handleCopyOut(PGconn *conn, FILE *copystream)
|
||||
* We must not ever return with the status still PGRES_COPY_OUT. Our
|
||||
* caller is unable to distinguish that situation from reaching the next
|
||||
* COPY in a command string that happened to contain two consecutive COPY
|
||||
* TO STDOUT commands. We trust that no condition can make PQexec() fail
|
||||
* TO STDOUT commands. We trust that no condition can make PQexec() fail
|
||||
* indefinitely while retaining status PGRES_COPY_OUT.
|
||||
*/
|
||||
while (res = PQgetResult(conn), PQresultStatus(res) == PGRES_COPY_OUT)
|
||||
@@ -584,6 +584,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
|
||||
OK = false;
|
||||
|
||||
copyin_cleanup:
|
||||
|
||||
/*
|
||||
* Check command status and return to normal libpq state
|
||||
*
|
||||
|
||||
@@ -142,15 +142,15 @@ describeTablespaces(const char *pattern, bool verbose)
|
||||
if (pset.sversion >= 90200)
|
||||
printfPQExpBuffer(&buf,
|
||||
"SELECT spcname AS \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
|
||||
" pg_catalog.pg_tablespace_location(oid) AS \"%s\"",
|
||||
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
|
||||
" pg_catalog.pg_tablespace_location(oid) AS \"%s\"",
|
||||
gettext_noop("Name"),
|
||||
gettext_noop("Owner"),
|
||||
gettext_noop("Location"));
|
||||
else
|
||||
printfPQExpBuffer(&buf,
|
||||
"SELECT spcname AS \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
|
||||
" spclocation AS \"%s\"",
|
||||
gettext_noop("Name"),
|
||||
gettext_noop("Owner"),
|
||||
@@ -910,7 +910,7 @@ objectDescription(const char *pattern, bool showSystem)
|
||||
|
||||
if (!showSystem && !pattern)
|
||||
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
|
||||
" AND n.nspname <> 'information_schema'\n");
|
||||
" AND n.nspname <> 'information_schema'\n");
|
||||
|
||||
processSQLNamePattern(pset.db, &buf, pattern, true, false,
|
||||
"n.nspname", "o.opcname", NULL,
|
||||
@@ -926,7 +926,7 @@ objectDescription(const char *pattern, bool showSystem)
|
||||
/* Operator family descriptions */
|
||||
appendPQExpBuffer(&buf,
|
||||
"UNION ALL\n"
|
||||
" SELECT opf.oid as oid, opf.tableoid as tableoid,\n"
|
||||
" SELECT opf.oid as oid, opf.tableoid as tableoid,\n"
|
||||
" n.nspname as nspname,\n"
|
||||
" CAST(opf.opfname AS pg_catalog.text) AS name,\n"
|
||||
" CAST('%s' AS pg_catalog.text) as object\n"
|
||||
@@ -939,7 +939,7 @@ objectDescription(const char *pattern, bool showSystem)
|
||||
|
||||
if (!showSystem && !pattern)
|
||||
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
|
||||
" AND n.nspname <> 'information_schema'\n");
|
||||
" AND n.nspname <> 'information_schema'\n");
|
||||
|
||||
processSQLNamePattern(pset.db, &buf, pattern, true, false,
|
||||
"n.nspname", "opf.opfname", NULL,
|
||||
@@ -1294,14 +1294,15 @@ describeOneTableDetails(const char *schemaname,
|
||||
appendPQExpBuffer(&buf, ",\n NULL AS indexdef");
|
||||
if (tableinfo.relkind == 'f' && pset.sversion >= 90200)
|
||||
appendPQExpBuffer(&buf, ",\n CASE WHEN attfdwoptions IS NULL THEN '' ELSE "
|
||||
" '(' || array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM "
|
||||
" pg_options_to_table(attfdwoptions)), ', ') || ')' END AS attfdwoptions");
|
||||
" '(' || array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM "
|
||||
" pg_options_to_table(attfdwoptions)), ', ') || ')' END AS attfdwoptions");
|
||||
else
|
||||
appendPQExpBuffer(&buf, ",\n NULL AS attfdwoptions");
|
||||
if (verbose)
|
||||
{
|
||||
appendPQExpBuffer(&buf, ",\n a.attstorage");
|
||||
appendPQExpBuffer(&buf, ",\n CASE WHEN a.attstattarget=-1 THEN NULL ELSE a.attstattarget END AS attstattarget");
|
||||
|
||||
/*
|
||||
* In 9.0+, we have column comments for: relations, views, composite
|
||||
* types, and foreign tables (c.f. CommentObject() in comment.c).
|
||||
@@ -1416,7 +1417,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
PGresult *result;
|
||||
|
||||
printfPQExpBuffer(&buf,
|
||||
"SELECT pg_catalog.pg_get_viewdef('%s'::pg_catalog.oid, true);",
|
||||
"SELECT pg_catalog.pg_get_viewdef('%s'::pg_catalog.oid, true);",
|
||||
oid);
|
||||
result = PSQLexec(buf.data, false);
|
||||
if (!result)
|
||||
@@ -1651,13 +1652,13 @@ describeOneTableDetails(const char *schemaname,
|
||||
"\n pg_catalog.quote_ident(relname) || '.' ||"
|
||||
"\n pg_catalog.quote_ident(attname)"
|
||||
"\nFROM pg_catalog.pg_class c"
|
||||
"\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
|
||||
"\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
|
||||
"\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
|
||||
"\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
|
||||
"\nINNER JOIN pg_catalog.pg_attribute a ON ("
|
||||
"\n a.attrelid=c.oid AND"
|
||||
"\n a.attnum=d.refobjsubid)"
|
||||
"\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
|
||||
"\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
|
||||
"\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
|
||||
"\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
|
||||
"\n AND d.objid=%s"
|
||||
"\n AND d.deptype='a'",
|
||||
oid);
|
||||
@@ -1671,10 +1672,11 @@ describeOneTableDetails(const char *schemaname,
|
||||
PQgetvalue(result, 0, 0));
|
||||
printTableAddFooter(&cont, buf.data);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get no rows back, don't show anything (obviously).
|
||||
* We should never get more than one row back, but if we do,
|
||||
* just ignore it and don't print anything.
|
||||
* If we get no rows back, don't show anything (obviously). We should
|
||||
* never get more than one row back, but if we do, just ignore it and
|
||||
* don't print anything.
|
||||
*/
|
||||
PQclear(result);
|
||||
}
|
||||
@@ -1711,7 +1713,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
" LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND conindid = i.indexrelid AND contype IN ('p','u','x'))\n");
|
||||
appendPQExpBuffer(&buf,
|
||||
"WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
|
||||
"ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname;",
|
||||
"ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname;",
|
||||
oid);
|
||||
result = PSQLexec(buf.data, false);
|
||||
if (!result)
|
||||
@@ -1823,7 +1825,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
"SELECT conname,\n"
|
||||
" pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n"
|
||||
"FROM pg_catalog.pg_constraint r\n"
|
||||
"WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1;",
|
||||
"WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1;",
|
||||
oid);
|
||||
result = PSQLexec(buf.data, false);
|
||||
if (!result)
|
||||
@@ -1854,7 +1856,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
"SELECT conname, conrelid::pg_catalog.regclass,\n"
|
||||
" pg_catalog.pg_get_constraintdef(c.oid, true) as condef\n"
|
||||
"FROM pg_catalog.pg_constraint c\n"
|
||||
"WHERE c.confrelid = '%s' AND c.contype = 'f' ORDER BY 1;",
|
||||
"WHERE c.confrelid = '%s' AND c.contype = 'f' ORDER BY 1;",
|
||||
oid);
|
||||
result = PSQLexec(buf.data, false);
|
||||
if (!result)
|
||||
@@ -2105,7 +2107,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
/* print foreign server name */
|
||||
if (tableinfo.relkind == 'f')
|
||||
{
|
||||
char *ftoptions;
|
||||
char *ftoptions;
|
||||
|
||||
/* Footer information about foreign table */
|
||||
printfPQExpBuffer(&buf,
|
||||
@@ -2113,7 +2115,7 @@ describeOneTableDetails(const char *schemaname,
|
||||
" array_to_string(ARRAY(SELECT "
|
||||
" quote_ident(option_name) || ' ' || "
|
||||
" quote_literal(option_value) FROM "
|
||||
" pg_options_to_table(ftoptions)), ', ') "
|
||||
" pg_options_to_table(ftoptions)), ', ') "
|
||||
"FROM pg_catalog.pg_foreign_table f,\n"
|
||||
" pg_catalog.pg_foreign_server s\n"
|
||||
"WHERE f.ftrelid = %s AND s.oid = f.ftserver;",
|
||||
@@ -2841,7 +2843,7 @@ listDomains(const char *pattern, bool verbose, bool showSystem)
|
||||
|
||||
appendPQExpBuffer(&buf,
|
||||
"\nFROM pg_catalog.pg_type t\n"
|
||||
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
|
||||
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
|
||||
|
||||
if (verbose)
|
||||
appendPQExpBuffer(&buf,
|
||||
@@ -3769,7 +3771,7 @@ listForeignDataWrappers(const char *pattern, bool verbose)
|
||||
initPQExpBuffer(&buf);
|
||||
printfPQExpBuffer(&buf,
|
||||
"SELECT fdw.fdwname AS \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n",
|
||||
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n",
|
||||
gettext_noop("Name"),
|
||||
gettext_noop("Owner"));
|
||||
if (pset.sversion >= 90100)
|
||||
|
||||
@@ -124,9 +124,9 @@ usage(void)
|
||||
printf(_(" -T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)\n"));
|
||||
printf(_(" -x, --expanded turn on expanded table output\n"));
|
||||
printf(_(" -z, --field-separator-zero\n"
|
||||
" set field separator to zero byte\n"));
|
||||
" set field separator to zero byte\n"));
|
||||
printf(_(" -0, --record-separator-zero\n"
|
||||
" set record separator to zero byte\n"));
|
||||
" set record separator to zero byte\n"));
|
||||
|
||||
printf(_("\nConnection options:\n"));
|
||||
/* Display default host */
|
||||
@@ -247,7 +247,7 @@ slashUsage(unsigned short int pager)
|
||||
ON(pset.popt.topt.tuples_only));
|
||||
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
|
||||
fprintf(output, _(" \\x [on|off|auto] toggle expanded output (currently %s)\n"),
|
||||
pset.popt.topt.expanded == 2 ? "auto" : ON(pset.popt.topt.expanded));
|
||||
pset.popt.topt.expanded == 2 ? "auto" : ON(pset.popt.topt.expanded));
|
||||
fprintf(output, "\n");
|
||||
|
||||
fprintf(output, _("Connection\n"));
|
||||
|
||||
@@ -288,7 +288,8 @@ initializeInput(int flags)
|
||||
|
||||
if (histfile == NULL)
|
||||
{
|
||||
char * envhist;
|
||||
char *envhist;
|
||||
|
||||
envhist = getenv("PSQL_HISTORY");
|
||||
if (envhist != NULL && strlen(envhist) > 0)
|
||||
histfile = envhist;
|
||||
|
||||
@@ -44,8 +44,8 @@ static char *decimal_point;
|
||||
static char *grouping;
|
||||
static char *thousands_sep;
|
||||
|
||||
static char default_footer[100];
|
||||
static printTableFooter default_footer_cell = { default_footer, NULL };
|
||||
static char default_footer[100];
|
||||
static printTableFooter default_footer_cell = {default_footer, NULL};
|
||||
|
||||
/* Line style control structures */
|
||||
const printTextFormat pg_asciiformat =
|
||||
@@ -283,7 +283,7 @@ print_separator(struct separator sep, FILE *fout)
|
||||
|
||||
/*
|
||||
* Return the list of explicitly-requested footers or, when applicable, the
|
||||
* default "(xx rows)" footer. Always omit the default footer when given
|
||||
* default "(xx rows)" footer. Always omit the default footer when given
|
||||
* non-default footers, "\pset footer off", or a specific instruction to that
|
||||
* effect from a calling backslash command. Vertical formats number each row,
|
||||
* making the default footer redundant; they do not call this function.
|
||||
@@ -388,6 +388,7 @@ print_unaligned_text(const printTableContent *cont, FILE *fout)
|
||||
need_recordsep = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The last record is terminated by a newline, independent of the set
|
||||
* record separator. But when the record separator is a zero byte, we
|
||||
|
||||
@@ -89,7 +89,7 @@ typedef struct printTableOpt
|
||||
unsigned long prior_records; /* start offset for record counters */
|
||||
const printTextFormat *line_style; /* line style (NULL for default) */
|
||||
struct separator fieldSep; /* field separator for unaligned text mode */
|
||||
struct separator recordSep; /* record separator for unaligned text mode */
|
||||
struct separator recordSep; /* record separator for unaligned text mode */
|
||||
bool numericLocale; /* locale-aware numeric units separator and
|
||||
* decimal marker */
|
||||
char *tableAttr; /* attributes for HTML <table ...> */
|
||||
@@ -162,9 +162,9 @@ extern void printTableInit(printTableContent *const content,
|
||||
const printTableOpt *opt, const char *title,
|
||||
const int ncolumns, const int nrows);
|
||||
extern void printTableAddHeader(printTableContent *const content,
|
||||
char *header, const bool translate, const char align);
|
||||
char *header, const bool translate, const char align);
|
||||
extern void printTableAddCell(printTableContent *const content,
|
||||
char *cell, const bool translate, const bool mustfree);
|
||||
char *cell, const bool translate, const bool mustfree);
|
||||
extern void printTableAddFooter(printTableContent *const content,
|
||||
const char *footer);
|
||||
extern void printTableSetFooter(printTableContent *const content,
|
||||
|
||||
@@ -591,7 +591,7 @@ process_psqlrc(char *argv0)
|
||||
char rc_file[MAXPGPATH];
|
||||
char my_exec_path[MAXPGPATH];
|
||||
char etc_path[MAXPGPATH];
|
||||
char *envrc;
|
||||
char *envrc;
|
||||
|
||||
find_my_exec(argv0, my_exec_path);
|
||||
get_etc_path(my_exec_path, etc_path);
|
||||
@@ -600,7 +600,7 @@ process_psqlrc(char *argv0)
|
||||
process_psqlrc_file(rc_file);
|
||||
|
||||
envrc = getenv("PSQLRC");
|
||||
|
||||
|
||||
if (envrc != NULL && strlen(envrc) > 0)
|
||||
{
|
||||
expand_tilde(&envrc);
|
||||
@@ -618,7 +618,8 @@ process_psqlrc(char *argv0)
|
||||
static void
|
||||
process_psqlrc_file(char *filename)
|
||||
{
|
||||
char *psqlrc_minor, *psqlrc_major;
|
||||
char *psqlrc_minor,
|
||||
*psqlrc_major;
|
||||
|
||||
#if defined(WIN32) && (!defined(__MINGW32__))
|
||||
#define R_OK 4
|
||||
|
||||
@@ -277,7 +277,7 @@ strip_quotes(char *source, char quote, char escape, int encoding)
|
||||
/*
|
||||
* quote_if_needed
|
||||
*
|
||||
* Opposite of strip_quotes(). If "source" denotes itself literally without
|
||||
* Opposite of strip_quotes(). If "source" denotes itself literally without
|
||||
* quoting or escaping, returns NULL. Otherwise, returns a malloc'd copy with
|
||||
* quoting and escaping applied:
|
||||
*
|
||||
@@ -303,7 +303,7 @@ quote_if_needed(const char *source, const char *entails_quote,
|
||||
psql_assert(quote);
|
||||
|
||||
src = source;
|
||||
dst = ret = pg_malloc(2 * strlen(src) + 3); /* excess */
|
||||
dst = ret = pg_malloc(2 * strlen(src) + 3); /* excess */
|
||||
|
||||
*dst++ = quote;
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ static const char *const * completion_charpp; /* to pass a list of strings */
|
||||
static const char *completion_info_charp; /* to pass a second string */
|
||||
static const char *completion_info_charp2; /* to pass a third string */
|
||||
static const SchemaQuery *completion_squery; /* to pass a SchemaQuery */
|
||||
static bool completion_case_sensitive; /* completion is case sensitive */
|
||||
static bool completion_case_sensitive; /* completion is case sensitive */
|
||||
|
||||
/*
|
||||
* A few macros to ease typing. You can use these to complete the given
|
||||
@@ -790,9 +790,9 @@ psql_completion(char *text, int start, int end)
|
||||
completion_info_charp2 = NULL;
|
||||
|
||||
/*
|
||||
* Scan the input line before our current position for the last few
|
||||
* words. According to those we'll make some smart decisions on what the
|
||||
* user is probably intending to type.
|
||||
* Scan the input line before our current position for the last few words.
|
||||
* According to those we'll make some smart decisions on what the user is
|
||||
* probably intending to type.
|
||||
*/
|
||||
get_previous_words(start, previous_words, lengthof(previous_words));
|
||||
|
||||
@@ -1041,7 +1041,7 @@ psql_completion(char *text, int start, int end)
|
||||
"ENCRYPTED", "INHERIT", "LOGIN", "NOCREATEDB", "NOCREATEROLE",
|
||||
"NOCREATEUSER", "NOINHERIT", "NOLOGIN", "NOREPLICATION",
|
||||
"NOSUPERUSER", "RENAME TO", "REPLICATION", "RESET", "SET",
|
||||
"SUPERUSER", "UNENCRYPTED", "VALID UNTIL", NULL};
|
||||
"SUPERUSER", "UNENCRYPTED", "VALID UNTIL", NULL};
|
||||
|
||||
COMPLETE_WITH_LIST(list_ALTERUSER_WITH);
|
||||
}
|
||||
@@ -2017,7 +2017,7 @@ psql_completion(char *text, int start, int end)
|
||||
"ENCRYPTED", "IN", "INHERIT", "LOGIN", "NOCREATEDB",
|
||||
"NOCREATEROLE", "NOCREATEUSER", "NOINHERIT", "NOLOGIN",
|
||||
"NOREPLICATION", "NOSUPERUSER", "REPLICATION", "ROLE",
|
||||
"SUPERUSER", "SYSID", "UNENCRYPTED", "VALID UNTIL", NULL};
|
||||
"SUPERUSER", "SYSID", "UNENCRYPTED", "VALID UNTIL", NULL};
|
||||
|
||||
COMPLETE_WITH_LIST(list_CREATEROLE_WITH);
|
||||
}
|
||||
@@ -2317,7 +2317,11 @@ psql_completion(char *text, int start, int end)
|
||||
" UNION SELECT 'USAGE'"
|
||||
" UNION SELECT 'ALL'");
|
||||
}
|
||||
/* Complete GRANT/REVOKE <privilege> with "ON", GRANT/REVOKE <role> with TO/FROM */
|
||||
|
||||
/*
|
||||
* Complete GRANT/REVOKE <privilege> with "ON", GRANT/REVOKE <role> with
|
||||
* TO/FROM
|
||||
*/
|
||||
else if (pg_strcasecmp(prev2_wd, "GRANT") == 0 ||
|
||||
pg_strcasecmp(prev2_wd, "REVOKE") == 0)
|
||||
{
|
||||
@@ -2901,8 +2905,11 @@ psql_completion(char *text, int start, int end)
|
||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
|
||||
|
||||
/* WITH [RECURSIVE] */
|
||||
/* Only match when WITH is the first word, as WITH may appear in many other
|
||||
contexts. */
|
||||
|
||||
/*
|
||||
* Only match when WITH is the first word, as WITH may appear in many
|
||||
* other contexts.
|
||||
*/
|
||||
else if (pg_strcasecmp(prev_wd, "WITH") == 0 &&
|
||||
prev2_wd[0] == '\0')
|
||||
COMPLETE_WITH_CONST("RECURSIVE");
|
||||
@@ -3029,7 +3036,7 @@ psql_completion(char *text, int start, int end)
|
||||
strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
|
||||
strcmp(prev_wd, "\\g") == 0 ||
|
||||
strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
|
||||
strcmp(prev_wd, "\\ir") == 0 || strcmp(prev_wd, "\\include_relative") == 0 ||
|
||||
strcmp(prev_wd, "\\ir") == 0 || strcmp(prev_wd, "\\include_relative") == 0 ||
|
||||
strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
|
||||
strcmp(prev_wd, "\\s") == 0 ||
|
||||
strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
|
||||
@@ -3412,8 +3419,11 @@ complete_from_list(const char *text, int state)
|
||||
if (completion_case_sensitive)
|
||||
return pg_strdup(item);
|
||||
else
|
||||
/* If case insensitive matching was requested initially, adjust
|
||||
* the case according to setting. */
|
||||
|
||||
/*
|
||||
* If case insensitive matching was requested initially,
|
||||
* adjust the case according to setting.
|
||||
*/
|
||||
return pg_strdup_keyword_case(item, text);
|
||||
}
|
||||
}
|
||||
@@ -3451,8 +3461,11 @@ complete_from_const(const char *text, int state)
|
||||
if (completion_case_sensitive)
|
||||
return pg_strdup(completion_charp);
|
||||
else
|
||||
/* If case insensitive matching was requested initially, adjust the
|
||||
* case according to setting. */
|
||||
|
||||
/*
|
||||
* If case insensitive matching was requested initially, adjust
|
||||
* the case according to setting.
|
||||
*/
|
||||
return pg_strdup_keyword_case(completion_charp, text);
|
||||
}
|
||||
else
|
||||
@@ -3500,7 +3513,7 @@ complete_from_variables(char *text, const char *prefix, const char *suffix)
|
||||
}
|
||||
|
||||
varnames[nvars] = NULL;
|
||||
COMPLETE_WITH_LIST_CS((const char * const *) varnames);
|
||||
COMPLETE_WITH_LIST_CS((const char *const *) varnames);
|
||||
|
||||
for (i = 0; i < nvars; i++)
|
||||
free(varnames[i]);
|
||||
@@ -3567,9 +3580,10 @@ complete_from_files(const char *text, int state)
|
||||
static char *
|
||||
pg_strdup_keyword_case(const char *s, const char *ref)
|
||||
{
|
||||
char *ret, *p;
|
||||
char *ret,
|
||||
*p;
|
||||
unsigned char first = ref[0];
|
||||
int tocase;
|
||||
int tocase;
|
||||
const char *varval;
|
||||
|
||||
varval = GetVariable(pset.vars, "COMP_KEYWORD_CASE");
|
||||
@@ -3635,7 +3649,7 @@ exec_query(const char *query)
|
||||
|
||||
|
||||
/*
|
||||
* Return the nwords word(s) before point. Words are returned right to left,
|
||||
* Return the nwords word(s) before point. Words are returned right to left,
|
||||
* that is, previous_words[0] gets the last word before point.
|
||||
* If we run out of words, remaining array elements are set to empty strings.
|
||||
* Each array element is filled with a malloc'd string.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* Check whether a variable's name is allowed.
|
||||
*
|
||||
* We allow any non-ASCII character, as well as ASCII letters, digits, and
|
||||
* underscore. Keep this in sync with the definition of variable_char in
|
||||
* underscore. Keep this in sync with the definition of variable_char in
|
||||
* psqlscan.l.
|
||||
*/
|
||||
static bool
|
||||
|
||||
Reference in New Issue
Block a user