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
b6335b4f
Commit
b6335b4f
authored
Jul 12, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tablespace location display for psql \d.
Gavin Sherry
parent
e47cbb3b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
13 deletions
+59
-13
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+2
-2
src/bin/psql/common.h
src/bin/psql/common.h
+4
-1
src/bin/psql/describe.c
src/bin/psql/describe.c
+52
-6
src/bin/psql/large_obj.c
src/bin/psql/large_obj.c
+1
-4
No files found.
doc/src/sgml/ref/psql-ref.sgml
View file @
b6335b4f
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.11
6 2004/06/18 06:13:05 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.11
7 2004/07/12 20:41:08 momjian
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -784,7 +784,7 @@ testdb=>
...
@@ -784,7 +784,7 @@ testdb=>
<para>
<para>
For each relation (table, view, index, or sequence) matching the
For each relation (table, view, index, or sequence) matching the
<replaceable class="parameter">pattern</replaceable>, show all
<replaceable class="parameter">pattern</replaceable>, show all
columns, their types, and any special
columns, their types,
the tablespace (if not the default)
and any special
attributes such as <literal>NOT NULL</literal> or defaults, if
attributes such as <literal>NOT NULL</literal> or defaults, if
any. Associated indexes, constraints, rules, and triggers are
any. Associated indexes, constraints, rules, and triggers are
also shown, as is the view definition if the relation is a view.
also shown, as is the view definition if the relation is a view.
...
...
src/bin/psql/common.h
View file @
b6335b4f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.3
7 2004/07/11 13:29:15
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.3
8 2004/07/12 20:41:13
momjian Exp $
*/
*/
#ifndef COMMON_H
#ifndef COMMON_H
#define COMMON_H
#define COMMON_H
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
#define psql_assert(p)
#define psql_assert(p)
#endif
#endif
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
/*
/*
* Safer versions of some standard C library functions. If an
* Safer versions of some standard C library functions. If an
* out-of-memory condition occurs, these functions will bail out
* out-of-memory condition occurs, these functions will bail out
...
...
src/bin/psql/describe.c
View file @
b6335b4f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.
99 2004/06/18 06:14:04 tgl
Exp $
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.
100 2004/07/12 20:41:13 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "describe.h"
#include "describe.h"
...
@@ -39,6 +39,9 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
...
@@ -39,6 +39,9 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
const
char
*
schemavar
,
const
char
*
namevar
,
const
char
*
schemavar
,
const
char
*
namevar
,
const
char
*
altnamevar
,
const
char
*
visibilityrule
);
const
char
*
altnamevar
,
const
char
*
visibilityrule
);
static
void
add_tablespace_footer
(
char
relkind
,
Oid
tablespace
,
char
**
footers
,
int
*
count
,
PQExpBufferData
buf
);
/*----------------
/*----------------
* Handlers for various slash commands displaying some sort of list
* Handlers for various slash commands displaying some sort of list
* of things in the database.
* of things in the database.
...
@@ -682,6 +685,7 @@ describeOneTableDetails(const char *schemaname,
...
@@ -682,6 +685,7 @@ describeOneTableDetails(const char *schemaname,
bool
hasindex
;
bool
hasindex
;
bool
hasrules
;
bool
hasrules
;
bool
hasoids
;
bool
hasoids
;
Oid
tablespace
;
}
tableinfo
;
}
tableinfo
;
bool
show_modifiers
=
false
;
bool
show_modifiers
=
false
;
bool
retval
;
bool
retval
;
...
@@ -694,7 +698,8 @@ describeOneTableDetails(const char *schemaname,
...
@@ -694,7 +698,8 @@ describeOneTableDetails(const char *schemaname,
/* Get general table info */
/* Get general table info */
printfPQExpBuffer
(
&
buf
,
printfPQExpBuffer
(
&
buf
,
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, relhasoids
\n
"
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules,
\n
"
"relhasoids, reltablespace
\n
"
"FROM pg_catalog.pg_class WHERE oid = '%s'"
,
"FROM pg_catalog.pg_class WHERE oid = '%s'"
,
oid
);
oid
);
res
=
PSQLexec
(
buf
.
data
,
false
);
res
=
PSQLexec
(
buf
.
data
,
false
);
...
@@ -717,6 +722,7 @@ describeOneTableDetails(const char *schemaname,
...
@@ -717,6 +722,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo
.
hasindex
=
strcmp
(
PQgetvalue
(
res
,
0
,
0
),
"t"
)
==
0
;
tableinfo
.
hasindex
=
strcmp
(
PQgetvalue
(
res
,
0
,
0
),
"t"
)
==
0
;
tableinfo
.
hasrules
=
strcmp
(
PQgetvalue
(
res
,
0
,
4
),
"t"
)
==
0
;
tableinfo
.
hasrules
=
strcmp
(
PQgetvalue
(
res
,
0
,
4
),
"t"
)
==
0
;
tableinfo
.
hasoids
=
strcmp
(
PQgetvalue
(
res
,
0
,
5
),
"t"
)
==
0
;
tableinfo
.
hasoids
=
strcmp
(
PQgetvalue
(
res
,
0
,
5
),
"t"
)
==
0
;
tableinfo
.
tablespace
=
atooid
(
PQgetvalue
(
res
,
0
,
6
));
PQclear
(
res
);
PQclear
(
res
);
headers
[
0
]
=
_
(
"Column"
);
headers
[
0
]
=
_
(
"Column"
);
...
@@ -897,6 +903,7 @@ describeOneTableDetails(const char *schemaname,
...
@@ -897,6 +903,7 @@ describeOneTableDetails(const char *schemaname,
char
*
indamname
=
PQgetvalue
(
result
,
0
,
3
);
char
*
indamname
=
PQgetvalue
(
result
,
0
,
3
);
char
*
indtable
=
PQgetvalue
(
result
,
0
,
4
);
char
*
indtable
=
PQgetvalue
(
result
,
0
,
4
);
char
*
indpred
=
PQgetvalue
(
result
,
0
,
5
);
char
*
indpred
=
PQgetvalue
(
result
,
0
,
5
);
int
count_footers
=
0
;
if
(
strcmp
(
indisprimary
,
"t"
)
==
0
)
if
(
strcmp
(
indisprimary
,
"t"
)
==
0
)
printfPQExpBuffer
(
&
tmpbuf
,
_
(
"PRIMARY KEY, "
));
printfPQExpBuffer
(
&
tmpbuf
,
_
(
"PRIMARY KEY, "
));
...
@@ -916,9 +923,12 @@ describeOneTableDetails(const char *schemaname,
...
@@ -916,9 +923,12 @@ describeOneTableDetails(const char *schemaname,
if
(
strcmp
(
indisclustered
,
"t"
)
==
0
)
if
(
strcmp
(
indisclustered
,
"t"
)
==
0
)
appendPQExpBuffer
(
&
tmpbuf
,
_
(
", CLUSTER"
));
appendPQExpBuffer
(
&
tmpbuf
,
_
(
", CLUSTER"
));
footers
=
pg_malloc_zero
(
2
*
sizeof
(
*
footers
));
footers
=
pg_malloc_zero
(
4
*
sizeof
(
*
footers
));
footers
[
0
]
=
pg_strdup
(
tmpbuf
.
data
);
footers
[
count_footers
++
]
=
pg_strdup
(
tmpbuf
.
data
);
footers
[
1
]
=
NULL
;
add_tablespace_footer
(
tableinfo
.
relkind
,
tableinfo
.
tablespace
,
footers
,
&
count_footers
,
tmpbuf
);
footers
[
count_footers
]
=
NULL
;
}
}
PQclear
(
result
);
PQclear
(
result
);
...
@@ -1103,7 +1113,7 @@ describeOneTableDetails(const char *schemaname,
...
@@ -1103,7 +1113,7 @@ describeOneTableDetails(const char *schemaname,
else
else
inherits_count
=
PQntuples
(
result6
);
inherits_count
=
PQntuples
(
result6
);
footers
=
pg_malloc_zero
((
index_count
+
check_count
+
rule_count
+
trigger_count
+
foreignkey_count
+
inherits_count
+
6
)
footers
=
pg_malloc_zero
((
index_count
+
check_count
+
rule_count
+
trigger_count
+
foreignkey_count
+
inherits_count
+
7
+
1
)
*
sizeof
(
*
footers
));
*
sizeof
(
*
footers
));
/* print indexes */
/* print indexes */
...
@@ -1236,6 +1246,8 @@ describeOneTableDetails(const char *schemaname,
...
@@ -1236,6 +1246,8 @@ describeOneTableDetails(const char *schemaname,
footers
[
count_footers
++
]
=
pg_strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_strdup
(
buf
.
data
);
}
}
add_tablespace_footer
(
tableinfo
.
relkind
,
tableinfo
.
tablespace
,
footers
,
&
count_footers
,
buf
);
/* end of list marker */
/* end of list marker */
footers
[
count_footers
]
=
NULL
;
footers
[
count_footers
]
=
NULL
;
...
@@ -1287,6 +1299,40 @@ error_return:
...
@@ -1287,6 +1299,40 @@ error_return:
}
}
static
void
add_tablespace_footer
(
char
relkind
,
Oid
tablespace
,
char
**
footers
,
int
*
count
,
PQExpBufferData
buf
)
{
/* relkinds for which we support tablespaces */
if
(
relkind
==
'r'
||
relkind
==
'i'
)
{
/*
* We ignore the database default tablespace so that users not
* using tablespaces don't need to know about them.
*/
if
(
tablespace
!=
0
)
{
PGresult
*
result1
=
NULL
;
printfPQExpBuffer
(
&
buf
,
"SELECT spcname FROM pg_tablespace
\n
"
"WHERE oid = '%u';"
,
tablespace
);
result1
=
PSQLexec
(
buf
.
data
,
false
);
if
(
!
result1
)
return
;
/* Should always be the case, but.... */
if
(
PQntuples
(
result1
)
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Tablespace:"
));
footers
[(
*
count
)
++
]
=
pg_strdup
(
buf
.
data
);
printfPQExpBuffer
(
&
buf
,
_
(
"
\"
%s
\"
"
),
PQgetvalue
(
result1
,
0
,
0
));
footers
[(
*
count
)
++
]
=
pg_strdup
(
buf
.
data
);
}
PQclear
(
result1
);
}
}
}
/*
/*
* \du
* \du
*
*
...
...
src/bin/psql/large_obj.c
View file @
b6335b4f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.3
1 2003/11/29 19:52:06 pgsql
Exp $
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.3
2 2004/07/12 20:41:13 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "large_obj.h"
#include "large_obj.h"
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
#include "print.h"
#include "print.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
/*
/*
* Prepare to do a large-object operation. We *must* be inside a transaction
* Prepare to do a large-object operation. We *must* be inside a transaction
* block for all these operations, so start one if needed.
* block for all these operations, so start one if needed.
...
...
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