Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48123de

Browse files
committed
Create the pg_pltemplate system catalog to hold template information
for procedural languages. This replaces the hard-wired table I hadoriginally proposed as a stopgap solution. For the moment, the initialcontents only include languages shipped with the core distribution.
1 parentc18cabe commit48123de

File tree

11 files changed

+313
-95
lines changed

11 files changed

+313
-95
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.112 2005/08/24 17:24:17 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.113 2005/09/08 20:07:41 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -168,6 +168,11 @@
168168
<entry>operators</entry>
169169
</row>
170170

171+
<row>
172+
<entry><link linkend="catalog-pg-pltemplate"><structname>pg_pltemplate</structname></link></entry>
173+
<entry>template data for procedural languages</entry>
174+
</row>
175+
171176
<row>
172177
<entry><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link></entry>
173178
<entry>functions and procedures</entry>
@@ -3027,6 +3032,106 @@
30273032
</sect1>
30283033

30293034

3035+
<sect1 id="catalog-pg-pltemplate">
3036+
<title><structname>pg_pltemplate</structname></title>
3037+
3038+
<indexterm zone="catalog-pg-pltemplate">
3039+
<primary>pg_pltemplate</primary>
3040+
</indexterm>
3041+
3042+
<para>
3043+
The catalog <structname>pg_pltemplate</structname> stores
3044+
<quote>template</> information for procedural languages.
3045+
A template for a language allows the language to be created in a
3046+
particular database by a simple <command>CREATE LANGUAGE</> command,
3047+
with no need to specify implementation details.
3048+
</para>
3049+
3050+
<para>
3051+
Unlike most system catalogs, <structname>pg_pltemplate</structname>
3052+
is shared across all databases of a cluster: there is only one
3053+
copy of <structname>pg_pltemplate</structname> per cluster, not
3054+
one per database. This allows the information to be accessible in
3055+
each database as it is needed.
3056+
</para>
3057+
3058+
<table>
3059+
<title><structname>pg_pltemplate</> Columns</title>
3060+
3061+
<tgroup cols=4>
3062+
<thead>
3063+
<row>
3064+
<entry>Name</entry>
3065+
<entry>Type</entry>
3066+
<entry>References</entry>
3067+
<entry>Description</entry>
3068+
</row>
3069+
</thead>
3070+
3071+
<tbody>
3072+
<row>
3073+
<entry><structfield>tmplname</structfield></entry>
3074+
<entry><type>name</type></entry>
3075+
<entry></entry>
3076+
<entry>Name of the language this template is for</entry>
3077+
</row>
3078+
3079+
<row>
3080+
<entry><structfield>tmpltrusted</structfield></entry>
3081+
<entry><type>boolean</type></entry>
3082+
<entry></entry>
3083+
<entry>True if language is considered trusted</entry>
3084+
</row>
3085+
3086+
<row>
3087+
<entry><structfield>tmplhandler</structfield></entry>
3088+
<entry><type>text</type></entry>
3089+
<entry></entry>
3090+
<entry>Name of call handler function</entry>
3091+
</row>
3092+
3093+
<row>
3094+
<entry><structfield>tmplvalidator</structfield></entry>
3095+
<entry><type>text</type></entry>
3096+
<entry></entry>
3097+
<entry>Name of validator function, or NULL if none</entry>
3098+
</row>
3099+
3100+
<row>
3101+
<entry><structfield>tmpllibrary</structfield></entry>
3102+
<entry><type>text</type></entry>
3103+
<entry></entry>
3104+
<entry>Path of shared library that implements language</entry>
3105+
</row>
3106+
3107+
<row>
3108+
<entry><structfield>tmplacl</structfield></entry>
3109+
<entry><type>aclitem[]</type></entry>
3110+
<entry></entry>
3111+
<entry>Access privileges for template (not yet used)</entry>
3112+
</row>
3113+
3114+
</tbody>
3115+
</tgroup>
3116+
</table>
3117+
3118+
<para>
3119+
There are not currently any commands that manipulate procedural language
3120+
templates; to change the built-in information, a superuser must modify
3121+
the table using ordinary INSERT, DELETE, or UPDATE commands. It is
3122+
likely that a future release of <productname>PostgreSQL</productname>
3123+
will offer commands to change the entries in a cleaner fashion.
3124+
</para>
3125+
3126+
<para>
3127+
When implemented, the <structfield>tmplacl</structfield> field will provide
3128+
access control for the template itself (i.e., the right to create a
3129+
language using it), not for the languages created from the template.
3130+
</para>
3131+
3132+
</sect1>
3133+
3134+
30303135
<sect1 id="catalog-pg-proc">
30313136
<title><structname>pg_proc</structname></title>
30323137

‎doc/src/sgml/ref/create_language.sgml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_language.sgml,v 1.40 2005/09/05 23:50:48 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_language.sgml,v 1.41 2005/09/08 20:07:41 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -48,22 +48,19 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">name</
4848

4949
<para>
5050
There are two forms of the <command>CREATE LANGUAGE</command> command.
51-
In the first form, the usermerelysupplies the name of the desired
51+
In the first form, the user supplies just the name of the desired
5252
language, and the <productname>PostgreSQL</productname> server consults
53-
an internal table to determine the correct parameters. In
54-
the second form, the user supplies the language parameters along with
55-
the language name. The second form must be used to create a language
56-
that is not present in the internal table, but this form is considered
57-
obsolescent. (It is expected that future releases of
58-
<productname>PostgreSQL</productname> will replace the internal table
59-
with a system catalog that can be extended to support additional
60-
languages.)
53+
the <link linkend="catalog-pg-pltemplate"><structname>pg_pltemplate</structname></link>
54+
system catalog to determine the correct parameters. In the second form,
55+
the user supplies the language parameters along with the language name.
56+
The second form can be used to create a language that is not defined in
57+
<structname>pg_pltemplate</>, but this approach is considered obsolescent.
6158
</para>
6259

6360
<para>
64-
When the server finds an entry inits internal table forthegiven
65-
language name, it will use thetable data even if the given command
66-
includes language parameters. This behavior simplifies loading of
61+
When the server finds an entry in the<structname>pg_pltemplate</> catalog
62+
for the givenlanguage name, it will use thecatalog data even if the
63+
commandincludes language parameters. This behavior simplifies loading of
6764
old dump files, which are likely to contain out-of-date information
6865
about language support functions.
6966
</para>
@@ -165,8 +162,8 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">name</
165162

166163
<para>
167164
The <literal>TRUSTED</> option and the support function name(s) are
168-
ignored if the server hasinformation about the specified language
169-
name inits internal table.
165+
ignored if the server hasan entry for the specified language
166+
name in<structname>pg_pltemplate</>.
170167
</para>
171168
</refsect1>
172169

@@ -207,9 +204,9 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">name</
207204

208205
<para>
209206
The call handler function and the validator function (if any)
210-
must already exist if the server does not haveinformation about
211-
the languageinits internal table. But when there is an entry
212-
in the internal table,the functions need not already exist;
207+
must already exist if the server does not havean entry for the language
208+
in<structname>pg_pltemplate</>. But when there is an entry,
209+
the functions need not already exist;
213210
they will be automatically defined if not present in the database.
214211
(This can result in <command>CREATE LANGUAGE</> failing, if the
215212
shared library that implements the language is not available in
@@ -239,8 +236,8 @@ CREATE LANGUAGE plpgsql;
239236
</para>
240237

241238
<para>
242-
For a language not known in theserver's internal table, a sequence
243-
such as this is needed:
239+
For a language not known in the<structname>pg_pltemplate</> catalog, a
240+
sequencesuch as this is needed:
244241
<programlisting>
245242
CREATE FUNCTION plsample_call_handler() RETURNS language_handler
246243
AS '$libdir/plsample'

‎doc/src/sgml/ref/createlang.sgml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/createlang.sgml,v 1.36 2005/09/05 23:50:48 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/createlang.sgml,v 1.37 2005/09/08 20:07:41 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -40,11 +40,9 @@ PostgreSQL documentation
4040
<para>
4141
<application>createlang</application> is a utility for adding a new
4242
programming language to a <productname>PostgreSQL</productname> database.
43-
<application>createlang</application> can handle all the languages
44-
supplied in the default <productname>PostgreSQL</> distribution, but
45-
not languages provided by other parties. See
43+
<application>createlang</application> is just a wrapper around the
4644
<xref linkend="sql-createlanguage" endterm="sql-createlanguage-title">
47-
for additional information.
45+
command, which seefor additional information.
4846
</para>
4947
</refsect1>
5048

‎src/backend/catalog/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for backend/catalog
44
#
5-
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.56 2005/07/14 05:13:39 tgl Exp $
5+
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.57 2005/09/08 20:07:41 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -32,8 +32,9 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
3232
pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
3333
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
3434
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
35-
pg_namespace.h pg_conversion.h pg_database.h pg_shdepend.h \
36-
pg_authid.h pg_auth_members.h pg_tablespace.h pg_depend.h \
35+
pg_namespace.h pg_conversion.h pg_depend.h \
36+
pg_database.h pg_tablespace.h pg_pltemplate.h \
37+
pg_authid.h pg_auth_members.h pg_shdepend.h \
3738
indexing.h \
3839
)
3940

‎src/backend/commands/functioncmds.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.66 2005/08/22 17:38:20 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.67 2005/09/08 20:07:41 tgl Exp $
1414
*
1515
* DESCRIPTION
1616
* These routines take the parse tree and pick out the
@@ -44,6 +44,7 @@
4444
#include"catalog/pg_proc.h"
4545
#include"catalog/pg_type.h"
4646
#include"commands/defrem.h"
47+
#include"commands/proclang.h"
4748
#include"miscadmin.h"
4849
#include"optimizer/cost.h"
4950
#include"parser/parse_func.h"
@@ -543,17 +544,11 @@ CreateFunction(CreateFunctionStmt *stmt)
543544
PointerGetDatum(languageName),
544545
0,0,0);
545546
if (!HeapTupleIsValid(languageTuple))
546-
/* Add any new languages to this list to invoke the hint. */
547547
ereport(ERROR,
548548
(errcode(ERRCODE_UNDEFINED_OBJECT),
549549
errmsg("language \"%s\" does not exist",languageName),
550-
(strcmp(languageName,"plperl")==0||
551-
strcmp(languageName,"plperlu")==0||
552-
strcmp(languageName,"plpgsql")==0||
553-
strcmp(languageName,"plpythonu")==0||
554-
strcmp(languageName,"pltcl")==0||
555-
strcmp(languageName,"pltclu")==0) ?
556-
errhint("You need to use \"createlang\" to load the language into the database.") :0));
550+
(PLTemplateExists(languageName) ?
551+
errhint("Use CREATE LANGUAGE to load the language into the database.") :0)));
557552

558553
languageOid=HeapTupleGetOid(languageTuple);
559554
languageStruct= (Form_pg_language)GETSTRUCT(languageTuple);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp