Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0ea1f6e9
Commit
0ea1f6e9
authored
Mar 03, 2013
by
Peter Eisentraut
Committed by
Magnus Hagander
Mar 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
psql: Let \l accept a pattern
reviewed by Satoshi Nagayasu
parent
54d6706d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
12 deletions
+30
-12
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+5
-4
src/bin/psql/command.c
src/bin/psql/command.c
+16
-4
src/bin/psql/describe.c
src/bin/psql/describe.c
+6
-1
src/bin/psql/describe.h
src/bin/psql/describe.h
+1
-1
src/bin/psql/help.c
src/bin/psql/help.c
+1
-1
src/bin/psql/startup.c
src/bin/psql/startup.c
+1
-1
No files found.
doc/src/sgml/ref/psql-ref.sgml
View file @
0ea1f6e9
...
...
@@ -1745,12 +1745,13 @@ hello 10
<varlistentry>
<term><literal>\l</literal> (or <literal>\list</literal>)</term>
<term><literal>\l+</literal> (or <literal>\list+</literal>)</term>
<term><literal>\l[+]</literal> or <literal>\list[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
<listitem>
<para>
List the names, owners, character set encodings, and access privileges
of all the databases in the server.
List the databases in the server and show their names, owners,
character set encodings, and access privileges.
If <replaceable class="parameter">pattern</replaceable> is specified,
only databases whose names match the pattern are listed.
If <literal>+</literal> is appended to the command name, database
sizes, default tablespaces, and descriptions are also displayed.
(Size information is only available for databases that the current
...
...
src/bin/psql/command.c
View file @
0ea1f6e9
...
...
@@ -821,10 +821,22 @@ exec_command(const char *cmd,
}
/* \l is list databases */
else
if
(
strcmp
(
cmd
,
"l"
)
==
0
||
strcmp
(
cmd
,
"list"
)
==
0
)
success
=
listAllDbs
(
false
);
else
if
(
strcmp
(
cmd
,
"l+"
)
==
0
||
strcmp
(
cmd
,
"list+"
)
==
0
)
success
=
listAllDbs
(
true
);
else
if
(
strcmp
(
cmd
,
"l"
)
==
0
||
strcmp
(
cmd
,
"list"
)
==
0
||
strcmp
(
cmd
,
"l+"
)
==
0
||
strcmp
(
cmd
,
"list+"
)
==
0
)
{
char
*
pattern
;
bool
show_verbose
;
pattern
=
psql_scan_slash_option
(
scan_state
,
OT_NORMAL
,
NULL
,
true
);
show_verbose
=
strchr
(
cmd
,
'+'
)
?
true
:
false
;
success
=
listAllDbs
(
pattern
,
show_verbose
);
if
(
pattern
)
free
(
pattern
);
}
/*
* large object things
...
...
src/bin/psql/describe.c
View file @
0ea1f6e9
...
...
@@ -641,7 +641,7 @@ describeOperators(const char *pattern, bool showSystem)
* for \l, \list, and -l switch
*/
bool
listAllDbs
(
bool
verbose
)
listAllDbs
(
const
char
*
pattern
,
bool
verbose
)
{
PGresult
*
res
;
PQExpBufferData
buf
;
...
...
@@ -684,6 +684,11 @@ listAllDbs(bool verbose)
if
(
verbose
&&
pset
.
sversion
>=
80000
)
appendPQExpBuffer
(
&
buf
,
" JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid
\n
"
);
if
(
pattern
)
processSQLNamePattern
(
pset
.
db
,
&
buf
,
pattern
,
false
,
false
,
NULL
,
"d.datname"
,
NULL
,
NULL
);
appendPQExpBuffer
(
&
buf
,
"ORDER BY 1;"
);
res
=
PSQLexec
(
buf
.
data
,
false
);
termPQExpBuffer
(
&
buf
);
...
...
src/bin/psql/describe.h
View file @
0ea1f6e9
...
...
@@ -55,7 +55,7 @@ extern bool listTSDictionaries(const char *pattern, bool verbose);
extern
bool
listTSTemplates
(
const
char
*
pattern
,
bool
verbose
);
/* \l */
extern
bool
listAllDbs
(
bool
verbose
);
extern
bool
listAllDbs
(
const
char
*
pattern
,
bool
verbose
);
/* \dt, \di, \ds, \dS, etc. */
extern
bool
listTables
(
const
char
*
tabtypes
,
const
char
*
pattern
,
bool
verbose
,
bool
showSystem
);
...
...
src/bin/psql/help.c
View file @
0ea1f6e9
...
...
@@ -235,7 +235,7 @@ slashUsage(unsigned short int pager)
fprintf
(
output
,
_
(
"
\\
dE[S+] [PATTERN] list foreign tables
\n
"
));
fprintf
(
output
,
_
(
"
\\
dx[+] [PATTERN] list extensions
\n
"
));
fprintf
(
output
,
_
(
"
\\
dy [PATTERN] list event triggers
\n
"
));
fprintf
(
output
,
_
(
"
\\
l[+]
list all
databases
\n
"
));
fprintf
(
output
,
_
(
"
\\
l[+]
[PATTERN] list
databases
\n
"
));
fprintf
(
output
,
_
(
"
\\
sf[+] FUNCNAME show a function's definition
\n
"
));
fprintf
(
output
,
_
(
"
\\
z [PATTERN] same as
\\
dp
\n
"
));
fprintf
(
output
,
"
\n
"
);
...
...
src/bin/psql/startup.c
View file @
0ea1f6e9
...
...
@@ -260,7 +260,7 @@ main(int argc, char *argv[])
if
(
!
options
.
no_psqlrc
)
process_psqlrc
(
argv
[
0
]);
success
=
listAllDbs
(
false
);
success
=
listAllDbs
(
NULL
,
false
);
PQfinish
(
pset
.
db
);
exit
(
success
?
EXIT_SUCCESS
:
EXIT_FAILURE
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment