Skip to content

Commit

Permalink
Tranlate pltcl.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
rjuju authored and gleu committed Jun 19, 2017
1 parent bfc4bcf commit 1108954
Showing 1 changed file with 104 additions and 99 deletions.
203 changes: 104 additions & 99 deletions postgresql/pltcl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ $$ LANGUAGE pltcl;
</para>

<para>
Le corps de la fonction est simplement un bout de script Tcl.
When the function is called, the argument values are passed to the
Tcl script as variables named <literal>1</literal>
... <literal><replaceable>n</replaceable></literal>. The result is
returned from the Tcl code in the usual way, with
a <literal>return</literal> statement.
Le corps de la fonction est simplement un bout de script Tcl. Quand la
fonction est appelée, les valeurs d'argument sont passées au script Tcl
comme des variables nommées <literal>1</literal>...
<literal><replaceable>n</replaceable></literal>. Le résultat est retournée
depuis le code Tcl de la manière habituelle, avec un ordre
<literal>return</literal>.
</para>

<para>
Expand Down Expand Up @@ -174,11 +174,11 @@ $$ LANGUAGE pltcl;
</para>

<para>
PL/Tcl functions can return composite-type results, too. To do this,
the Tcl code must return a list of column name/value pairs matching
the expected result type. Any column names omitted from the list
are returned as nulls, and an error is raised if there are unexpected
column names. Here is an example:
Les fonctions PL/Tcl peuvent également retourner des résultats de type
composite. Pour cela, le code Tcl doit retourner une liste de paires nom
de colonnes / valeurs correspondant au type de résultat attendu. Tout nom
de colonne omis de la liste sera retourné comme NULL, et une erreur est
levée s'il y a un nom de colonne inattendu. Voici un exemple :

<programlisting>
CREATE FUNCTION square_cube(in int, out squared int, out cubed int) AS $$
Expand All @@ -189,8 +189,9 @@ $$ LANGUAGE pltcl;

<tip>
<para>
The result list can be made from an array representation of the
desired tuple with the <literal>array get</literal> Tcl command. For example:
La liste résultat peut être faite à partir d'une représentation de
tableau du tuple désiré avec la commande Tcl <literal>array
get</literal>. Par exemple:

<programlisting>
CREATE FUNCTION raise_pay(employee, delta int) RETURNS employee AS $$
Expand All @@ -202,11 +203,12 @@ $$ LANGUAGE pltcl;
</tip>

<para>
PL/Tcl functions can return sets. To do this, the Tcl code should
call <function>return_next</function> once per row to be returned,
passing either the appropriate value when returning a scalar type,
or a list of column name/value pairs when returning a composite type.
Here is an example returning a scalar type:
Les fonctions PL/Tcl peuvent retourner des ensembles. Pour cela, le code
Tcl devrait appeler <function>return_next</function> une fois par ligne à
être retournée, passant soit la valeur appropriée quand un type scalaire
est retourné, soit une liste de paires de nom de colonne / valeur quand un
type composite est retourné. Voici un exemple retournant un type scalaire
:

<programlisting>
CREATE FUNCTION sequence(int, int) RETURNS SETOF int AS $$
Expand All @@ -216,7 +218,7 @@ CREATE FUNCTION sequence(int, int) RETURNS SETOF int AS $$
$$ LANGUAGE pltcl;
</programlisting>

and here is one returning a composite type:
et voici un exemple retournant un type composite :

<programlisting>
CREATE FUNCTION table_of_squares(int, int) RETURNS TABLE (x int, x2 int) AS $$
Expand All @@ -234,10 +236,11 @@ $$ LANGUAGE pltcl;
<para>
Les valeurs des arguments fournies au code d'une fonction PL/Tcl sont
simplement les arguments en entrée convertis au format texte (comme s'ils
avaient été affichés par une instruction <command>SELECT</command>).
<literal>return</literal> and <literal>return_next</literal> commands will accept
any string that is acceptable input format for the function's declared
result type, or for the specified column of a composite result type.
avaient été affichés par une instruction <command>SELECT</command>). Les
commandes <literal>return</literal> et <literal>return_next</literal>
accepteront toute chaîne qui est un format d'entrée acceptable pour le type
de résultat déclaré pour la fonction, ou pour la colonne spécifiée d'un type
de retour composite.
</para>

</sect1>
Expand Down Expand Up @@ -878,22 +881,22 @@ CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE PROCEDURE tclsnit
Le code Tcl contenu ou appelé à partir d'une fonction PL/Tcl peut lever
une erreur, soit en exécutant des opérations invalides ou en générant
une erreur en utilisant la commande Tcl <function>error</function> ou la
commande PL/Tcl <function>elog</function>. If an
error is not caught but is allowed to propagate out to the top level of
execution of the PL/Tcl function, it is reported as a SQL error in the
function's calling query.
commande PL/Tcl <function>elog</function>. Si une erreur n'est pas
rattrapée mais est autorisée à être propagée en dehors du niveau racine de
l'exécution de la fonction PL/Tcl, elle est rapportée comme une erreur SQL
dans la requête appelant la fonction.
</para>

<para>
Les erreurs SQL survenant dans les commandes PL/Tcl
<function>spi_exec</function>, <function>spi_prepare</function>
et <function>spi_execp</function> sont rapportées comme des erreurs Tcl,
donc elles sont récupérables par la commande Tcl <function>catch</function>.
(Each of these PL/Tcl commands runs its SQL operation in a
subtransaction, which is rolled back on error, so that any
partially-completed operation is automatically cleaned up.)
Again, if an error propagates out to the top level without being caught,
it turns back into a SQL error.
(Chacune des ces commandes PL/Tcl exécutent leurs opérations SQL dans une
sous transaction, qui est annulée en cas d'erreur, si bien que n'importe
quelle opération partiellement terminée sera automatiquement nettoyée.)
De la même façon, si une erreur se propage en dehors du niveau racine sans
avoir été rattrapée, elle sera rapportée en erreur SQL.
</para>

<para>
Expand Down Expand Up @@ -943,24 +946,24 @@ if {[catch { spi_exec $sql_command }]} {
</sect1>

<sect1 id="pltcl-subtransactions">
<title>Explicit Subtransactions in PL/Tcl</title>
<title>Sous-transactions explicites dans PL/Tcl</title>

<indexterm>
<primary>subtransactions</primary>
<secondary>in PL/Tcl</secondary>
<primary>sous-transactions</primary>
<secondary>dans PL/Tcl</secondary>
</indexterm>

<para>
Recovering from errors caused by database access as described in
<xref linkend="pltcl-error-handling"/> can lead to an undesirable
situation where some operations succeed before one of them fails,
and after recovering from that error the data is left in an
inconsistent state. PL/Tcl offers a solution to this problem in
the form of explicit subtransactions.
Récupérer des erreurs causées par des à la base de données comme décris
dans <xref linkend="pltcl-error-handling"/> peut mener à une situation
indésirable où certaines opérations réussissent avant que l'une d'entre
elles échoue, et après avoir récupéré cette erreur la donnée est laissé
dans un état incohérent. PL/Tcl offre une solution à ce problème sous la
forme de sous-transactions explicites :
</para>

<para>
Consider a function that implements a transfer between two accounts:
Étudions une fonction qui implémente un transfert entre deux compte :
<programlisting>
CREATE FUNCTION transfer_funds() RETURNS void AS $$
if [catch {
Expand All @@ -974,21 +977,20 @@ CREATE FUNCTION transfer_funds() RETURNS void AS $$
spi_exec "INSERT INTO operations (result) VALUES ('[quote $result]')"
$$ LANGUAGE pltcl;
</programlisting>
If the second <command>UPDATE</command> statement results in an
exception being raised, this function will log the failure, but
the result of the first <command>UPDATE</command> will
nevertheless be committed. In other words, the funds will be
withdrawn from Joe's account, but will not be transferred to
Mary's account. This happens because each <function>spi_exec</function>
is a separate subtransaction, and only one of those subtransactions
got rolled back.
Si le deuxième ordre <command>UPDATE</command> échoue en levant une
exception, cette fonction tracera l'échec, mais le résultat du premier
<command>UPDATE</command> sera néanmoins validé. Concrètement, le montant
sera débité du compte de Joe, mais ne sera pas transféré sur le compte de
Mary. C'est le cas car chaque appel à <function>spi_exec</function> est
une sous-transaction séparé, et seule l'une de ces sous-transactions est
annulée.
</para>

<para>
To handle such cases, you can wrap multiple database operations in an
explicit subtransaction, which will succeed or roll back as a whole.
PL/Tcl provides a <function>subtransaction</function> command to manage
this. We can rewrite our function as:
Pour gérer un cas comme ça, vous pouvez entourer vos opération sur la base
d'une sous-transaction explicite, qui sera annulée ou validée comme un
tour. PL/Tcl fournit une commande <function>subtransaction</function>
pour gérer ça. Nous pouvons réécrire notre fonction ainsi :
<programlisting>
CREATE FUNCTION transfer_funds2() RETURNS void AS $$
if [catch {
Expand All @@ -1004,32 +1006,32 @@ CREATE FUNCTION transfer_funds2() RETURNS void AS $$
spi_exec "INSERT INTO operations (result) VALUES ('[quote $result]')"
$$ LANGUAGE pltcl;
</programlisting>
Note that use of <function>catch</function> is still required for this
purpose. Otherwise the error would propagate to the top level of the
function, preventing the desired insertion into
the <structname>operations</structname> table.
The <function>subtransaction</function> command does not trap errors, it
only assures that all database operations executed inside its scope will
be rolled back together when an error is reported.
Veuillez noter que l'utilisation de <function>catch</function> est
toujours nécessaire pour gérer ce cas. Autrement l'erreur se propagerait
jusqu'au niveau racine de la fonction, ce qui empêcherait l'insertion
voulue dans la table <structname>operations</structname>. La commande
<function>subtransaction</function> ne récupère pas les erreurs, elle
s'assure seulement que tous les ordres sur la base exécutés dans sa portée
seront annulés ensemble si une erreur survient.
</para>

<para>
A rollback of an explicit subtransaction occurs on any error reported
by the contained Tcl code, not only errors originating from database
access. Thus a regular Tcl exception raised inside
a <function>subtransaction</function> command will also cause the
subtransaction to be rolled back. However, non-error exits out of the
contained Tcl code (for instance, due to <function>return</function>) do
not cause a rollback.
L'annulation d'une sous-transaction explicite arrive lors de n'importe
quelle erreur rapportée par le code Tcl contenu, pas uniquement pour celle
en provenance de la base de données. Ainsi une exception standard Tcl
levée dans une commande <function>subtransaction</function> aura également
pour effet d'annuler la sous-transaction. Toutefois, les sortie du code
Tcl contenu sans erreur (par exemple, du fait d'un
<function>return</function>) ne déclencheront pas d'annulation.
</para>
</sect1>

<sect1 id="pltcl-config">
<title>PL/Tcl Configuration</title>
<title>Configuration PL/Tcl</title>

<para>
This section lists configuration parameters that
affect <application>PL/Tcl</application>.
Cette section liste les paramètre de configuration qui affectent
<application>PL/Tcl</application>.
</para>

<variablelist>
Expand All @@ -1038,40 +1040,43 @@ $$ LANGUAGE pltcl;
<term>
<varname>pltcl.start_proc</varname> (<type>string</type>)
<indexterm>
<primary><varname>pltcl.start_proc</varname> configuration parameter</primary>
<primary>paramètre de configuration <varname>pltcl.start_proc</varname> </primary>
</indexterm>
</term>
<listitem>
<para>
This parameter, if set to a nonempty string, specifies the name
(possibly schema-qualified) of a parameterless PL/Tcl function that
is to be executed whenever a new Tcl interpreter is created for
PL/Tcl. Such a function can perform per-session initialization, such
as loading additional Tcl code. A new Tcl interpreter is created
when a PL/Tcl function is first executed in a database session, or
when an additional interpreter has to be created because a PL/Tcl
function is called by a new SQL role.
Ce paramètre, s'il est positionné à autre chose qu'une chaîne vide,
spécifie le nom (potentiellement qualifié du schéma) d'ue fonction
PL/Tcl sans paramètre qui doit être exécutée chaque fois qu'un nouvel
interpréteur Tcl est crée pour Pl/Tcl. Une telle fonction peut
effectuer une initialisation pour la session, comme charger du code Tcl
additionnel. Un nouvel interpréteur Tcl est créé wuen une fonction
PL/Tcl est exécutée pour la première fois dans une session, ou quand un
autre interpréteur doit être crée du fait de l'appel à une fonction
PL/Tcl par un nouveau rôle SQL.
</para>
<para>
The referenced function must be written in the <literal>pltcl</literal>
language, and must not be marked <literal>SECURITY DEFINER</literal>.
(These restrictions ensure that it runs in the interpreter it's
supposed to initialize.) The current user must have permission to
call it, too.
La fonction référencée doit être écrite dans le langage
<literal>pltcl</literal>, et ne doit pas être marquée comme
<literal>SECURITY DEFINER</literal>. (Ces restrictions s'assurent que
la fonction est lancée dans l'interpréteur qu'elle est censée
initialisée.) L'utilisateur courant doit avoir l'autorisation
d'appeler cette fonction également.
</para>
<para>
If the function fails with an error it will abort the function call
that caused the new interpreter to be created and propagate out to
the calling query, causing the current transaction or subtransaction
to be aborted. Any actions already done within Tcl won't be undone;
however, that interpreter won't be used again. If the language is
used again the initialization will be attempted again within a fresh
Tcl interpreter.
Si la fonction échoue avec une erreur cela annulera l'appel à la
fonction qui a causée la création du nouvel interpréteur et l'erreur
sera propagée jusqu'à la requête appelante, annulant de fait la
transaction ou sous transaction courante. Toute action déjà effectuée
au sein de Tcl ne sera pas annulée; toutefois, cette interpréteur ne
sera jamais réutilisé. Si le langage est utilisé à nouveau
l'initialisation sera de nouveau tentée avec une nouvel interpréteur
Tcl.
</para>
<para>
Only superusers can change this setting. Although this setting
can be changed within a session, such changes will not affect Tcl
interpreters that have already been created.
Seuls les superutilisateurs peuvent modifier ce paramètre. Bien que ce
paramètre puisse être changé au sein d'une session, un tel changement
n'affectera pas les interpréteurs Tcl qui ont déjà été créés.
</para>
</listitem>
</varlistentry>
Expand All @@ -1080,14 +1085,14 @@ $$ LANGUAGE pltcl;
<term>
<varname>pltclu.start_proc</varname> (<type>string</type>)
<indexterm>
<primary><varname>pltclu.start_proc</varname> configuration parameter</primary>
<primary>paramètre de configuration <varname>pltclu.start_proc</varname></primary>
</indexterm>
</term>
<listitem>
<para>
This parameter is exactly like <varname>pltcl.start_proc</varname>,
except that it applies to PL/TclU. The referenced function must
be written in the <literal>pltclu</literal> language.
Ce paramètre est exactement comme <varname>pltcl.start_proc</varname>,
sauf qu'il s'applique à PL/TclU. La fonction référencée doit être
écrite dans le langage <literal>pltclu</literal>.
</para>
</listitem>
</varlistentry>
Expand Down

0 comments on commit 1108954

Please sign in to comment.