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
52347b66
Commit
52347b66
authored
Jul 30, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pretty-printing variants of pg_get_viewdef and related functions.
Patch from Andreas Pflug.
parent
12911ea2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
951 additions
and
193 deletions
+951
-193
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+57
-6
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/ruleutils.c
+870
-183
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+15
-1
src/include/utils/builtins.h
src/include/utils/builtins.h
+7
-1
No files found.
doc/src/sgml/func.sgml
View file @
52347b66
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.16
1 2003/07/29 00:03:17
tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.16
2 2003/07/30 22:56:23
tgl Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -6494,10 +6494,9 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
...
@@ -6494,10 +6494,9 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
<para>
<para>
The function <function>current_setting</function> yields the
The function <function>current_setting</function> yields the
current value of the setting <parameter>setting_name</parameter>,
current value of the setting <parameter>setting_name</parameter>.
as part of a query result. It corresponds to the
It corresponds to the <acronym>SQL</acronym> command
<acronym>SQL</acronym> command <command>SHOW</command>. An
<command>SHOW</command>. An example:
example:
<programlisting>
<programlisting>
SELECT current_setting('datestyle');
SELECT current_setting('datestyle');
...
@@ -6832,6 +6831,10 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -6832,6 +6831,10 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<primary>pg_get_constraintdef</primary>
<primary>pg_get_constraintdef</primary>
</indexterm>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_get_expr</primary>
</indexterm>
<indexterm zone="functions-misc">
<indexterm zone="functions-misc">
<primary>pg_get_userbyid</primary>
<primary>pg_get_userbyid</primary>
</indexterm>
</indexterm>
...
@@ -6846,7 +6849,16 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -6846,7 +6849,16 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<function>pg_get_constraintdef</function> respectively
<function>pg_get_constraintdef</function> respectively
reconstruct the creating command for a view, rule, index, or
reconstruct the creating command for a view, rule, index, or
constraint. (Note that this is a decompiled reconstruction, not
constraint. (Note that this is a decompiled reconstruction, not
the verbatim text of the command.)
the original text of the command.) Most of these come in two
variants, one of which can optionally <quote>pretty-print</> the result.
The pretty-printed form is more readable but is less likely to be
interpreted the same way by future versions of <productname>PostgreSQL</>;
avoid using pretty-printed output for dump purposes.
Passing <literal>false</> for the pretty-print parameter yields the
same result as the variant that does not have the parameter at all.
<function>pg_get_expr</function> decompiles the internal form of an
individual expression, such as the default value for a column. It
may be useful when examining the contents of system catalogs.
<function>pg_get_userbyid</function>
<function>pg_get_userbyid</function>
extracts a user's name given a user ID number.
extracts a user's name given a user ID number.
</para>
</para>
...
@@ -6864,21 +6876,43 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -6864,21 +6876,43 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
<entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
</row>
</row>
<row>
<entry><literal><function>pg_get_viewdef</function>(<parameter>view_name</parameter>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
</row>
<row>
<row>
<entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>)</literal></entry>
<entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>)</literal></entry>
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE VIEW</> command for view</entry>
<entry>get <command>CREATE VIEW</> command for view</entry>
</row>
</row>
<row>
<entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE VIEW</> command for view</entry>
</row>
<row>
<row>
<entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>)</literal></entry>
<entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>)</literal></entry>
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE RULE</> command for rule</entry>
<entry>get <command>CREATE RULE</> command for rule</entry>
</row>
</row>
<row>
<entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE RULE</> command for rule</entry>
</row>
<row>
<row>
<entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>)</literal></entry>
<entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>)</literal></entry>
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE INDEX</> command for index</entry>
<entry>get <command>CREATE INDEX</> command for index</entry>
</row>
</row>
<row>
<entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>, <parameter>column_no</>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>get <command>CREATE INDEX</> command for index,
or definition of just one index column when
<parameter>column_no</> is not zero</entry>
</row>
<row>
<row>
<entry><function>pg_get_triggerdef</function>(<parameter>trigger_oid</parameter>)</entry>
<entry><function>pg_get_triggerdef</function>(<parameter>trigger_oid</parameter>)</entry>
<entry><type>text</type></entry>
<entry><type>text</type></entry>
...
@@ -6889,6 +6923,23 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -6889,6 +6923,23 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry>get definition of a constraint</entry>
<entry>get definition of a constraint</entry>
</row>
</row>
<row>
<entry><literal><function>pg_get_constraintdef</function>(<parameter>constraint_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>get definition of a constraint</entry>
</row>
<row>
<entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>)</literal></entry>
<entry><type>text</type></entry>
<entry>decompile internal form of an expression, assuming that any Vars
in it refer to the relation indicated by the second parameter</entry>
</row>
<row>
<entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>, <parameter>pretty_bool</>)</literal></entry>
<entry><type>text</type></entry>
<entry>decompile internal form of an expression, assuming that any Vars
in it refer to the relation indicated by the second parameter</entry>
</row>
<row>
<row>
<entry><literal><function>pg_get_userbyid</function>(<parameter>userid</parameter>)</literal></entry>
<entry><literal><function>pg_get_userbyid</function>(<parameter>userid</parameter>)</literal></entry>
<entry><type>name</type></entry>
<entry><type>name</type></entry>
...
...
src/backend/utils/adt/ruleutils.c
View file @
52347b66
This diff is collapsed.
Click to expand it.
src/include/catalog/catversion.h
View file @
52347b66
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: catversion.h,v 1.20
3 2003/07/29 17:21:27
tgl Exp $
* $Id: catversion.h,v 1.20
4 2003/07/30 22:56:24
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -53,6 +53,6 @@
...
@@ -53,6 +53,6 @@
*/
*/
/* yyyymmddN */
/* yyyymmddN */
#define CATALOG_VERSION_NO 200307
29
1
#define CATALOG_VERSION_NO 200307
30
1
#endif
#endif
src/include/catalog/pg_proc.h
View file @
52347b66
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: pg_proc.h,v 1.3
09 2003/07/01 00:04:38
tgl Exp $
* $Id: pg_proc.h,v 1.3
10 2003/07/30 22:56:24
tgl Exp $
*
*
* NOTES
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
* The script catalog/genbki.sh reads this file and generates .bki
...
@@ -3405,6 +3405,20 @@ DESCR("I/O");
...
@@ -3405,6 +3405,20 @@ DESCR("I/O");
DATA
(
insert
OID
=
2503
(
anyarray_send
PGNSP
PGUID
12
f
f
t
f
s
1
17
"2277"
anyarray_send
-
_null_
));
DATA
(
insert
OID
=
2503
(
anyarray_send
PGNSP
PGUID
12
f
f
t
f
s
1
17
"2277"
anyarray_send
-
_null_
));
DESCR
(
"I/O"
);
DESCR
(
"I/O"
);
/* System-view support functions with pretty-print option */
DATA
(
insert
OID
=
2504
(
pg_get_ruledef
PGNSP
PGUID
12
f
f
t
f
s
2
25
"26 16"
pg_get_ruledef_ext
-
_null_
));
DESCR
(
"source text of a rule with pretty-print option"
);
DATA
(
insert
OID
=
2505
(
pg_get_viewdef
PGNSP
PGUID
12
f
f
t
f
s
2
25
"25 16"
pg_get_viewdef_name_ext
-
_null_
));
DESCR
(
"select statement of a view with pretty-print option"
);
DATA
(
insert
OID
=
2506
(
pg_get_viewdef
PGNSP
PGUID
12
f
f
t
f
s
2
25
"26 16"
pg_get_viewdef_ext
-
_null_
));
DESCR
(
"select statement of a view with pretty-print option"
);
DATA
(
insert
OID
=
2507
(
pg_get_indexdef
PGNSP
PGUID
12
f
f
t
f
s
3
25
"26 23 16"
pg_get_indexdef_ext
-
_null_
));
DESCR
(
"index description (full create statement or single expression) with pretty-print option"
);
DATA
(
insert
OID
=
2508
(
pg_get_constraintdef
PGNSP
PGUID
12
f
f
t
f
s
2
25
"26 16"
pg_get_constraintdef_ext
-
_null_
));
DESCR
(
"constraint description with pretty-print option"
);
DATA
(
insert
OID
=
2509
(
pg_get_expr
PGNSP
PGUID
12
f
f
t
f
s
3
25
"25 26 16"
pg_get_expr_ext
-
_null_
));
DESCR
(
"deparse an encoded expression with pretty-print option"
);
/*
/*
* Symbolic values for provolatile column: these indicate whether the result
* Symbolic values for provolatile column: these indicate whether the result
...
...
src/include/utils/builtins.h
View file @
52347b66
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: builtins.h,v 1.22
3 2003/06/27 00:33:26
tgl Exp $
* $Id: builtins.h,v 1.22
4 2003/07/30 22:56:24
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -441,13 +441,19 @@ extern char *format_operator(Oid operator_oid);
...
@@ -441,13 +441,19 @@ extern char *format_operator(Oid operator_oid);
/* ruleutils.c */
/* ruleutils.c */
extern
Datum
pg_get_ruledef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_ruledef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_ruledef_ext
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef_ext
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef_name
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef_name
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_viewdef_name_ext
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_indexdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_indexdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_indexdef_ext
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_triggerdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_triggerdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_constraintdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_constraintdef
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_constraintdef_ext
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_userbyid
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_userbyid
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_expr
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_expr
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_expr_ext
(
PG_FUNCTION_ARGS
);
extern
char
*
deparse_expression
(
Node
*
expr
,
List
*
dpcontext
,
extern
char
*
deparse_expression
(
Node
*
expr
,
List
*
dpcontext
,
bool
forceprefix
,
bool
showimplicit
);
bool
forceprefix
,
bool
showimplicit
);
extern
List
*
deparse_context_for
(
const
char
*
aliasname
,
Oid
relid
);
extern
List
*
deparse_context_for
(
const
char
*
aliasname
,
Oid
relid
);
...
...
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