From wagner@imsd.uni-mainz.de Wed Jul 18 09:00:32 2001 Received: from yara.imsd.uni-mainz.de (yara.IMSD.Uni-Mainz.DE [134.93.144.68]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6I90Wa77009 for ; Wed, 18 Jul 2001 05:00:32 -0400 (EDT) (envelope-from wagner@imsd.uni-mainz.de) Received: (from smap@localhost) by yara.imsd.uni-mainz.de (8.9.3/8.9.3/lxs_5.2) id KAA06398 for ; Wed, 18 Jul 2001 10:59:52 +0200 Received: from hermes.imsd.uni-mainz.de(134.93.64.80) by yara.imsd.uni-mainz.de via smap (V2.1/2.1+anti-relay+anti-spam) id xma006387; Wed, 18 Jul 01 10:59:29 +0200 Received: from imsd.uni-mainz.de (unverified [134.93.64.34]) by hermes.imsd.uni-mainz.de (EMWAC SMTPRS 0.83) with SMTP id ; Wed, 18 Jul 2001 10:58:47 +0200 Message-ID: <3B55445B.36E16A4@imsd.uni-mainz.de> Date: Wed, 18 Jul 2001 10:10:03 +0200 From: Markus Wagner Organization: IMSD X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.13 i686) X-Accept-Language: en MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: SPI_exec does not return! Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200107/241 X-Sequence-Number: 4037 Hi, if I do a SELECT on a non-existing table, SPI_exec won't return. I get, e. g. in pgaccess, an error message " does not exist", and my code below the function call is never reached. So why return error codes for SPI_exec when you cannot evaluate them? The background: I need to distinguish different client connections within a trigger function. To do this, I create a temporary table within a "login" function. My trigger must check for the existence of this function. I cannot think of any other method, since there is no "connection id" or something like that! This would also be an application for checking the existance of a temporary table, as was asked for in another thread in this list before. How can I check for the existence of a temporary table without getting interuppted????? Thanks, Markus From JanWieck@Yahoo.com Wed Jul 18 10:48:33 2001 Received: from smtp018.mail.yahoo.com (smtp018.mail.yahoo.com [216.136.174.115]) by postgresql.org (8.11.3/8.11.1) with SMTP id f6IAmXa21609 for ; Wed, 18 Jul 2001 06:48:33 -0400 (EDT) (envelope-from janwieck@yahoo.com) Received: from jupiter.us.greatbridge.com (65.196.69.55) by smtp.mail.vip.sc5.yahoo.com with SMTP; 18 Jul 2001 10:48:29 -0000 X-Apparently-From: Received: (from wieck@localhost) by jupiter.us.greatbridge.com (8.11.2/8.11.2) id f6IAsYd20969; Wed, 18 Jul 2001 06:54:34 -0400 From: Jan Wieck Message-Id: <200107181054.f6IAsYd20969@jupiter.us.greatbridge.com> Subject: Re: SPI_exec does not return! In-Reply-To: <3B55445B.36E16A4@imsd.uni-mainz.de> from Markus Wagner at "Jul 18, 2001 10:10:03 am" To: Markus Wagner Date: Wed, 18 Jul 2001 06:54:34 -0400 (EDT) CC: "pgsql-sql@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200107/243 X-Sequence-Number: 4039 Markus Wagner wrote: > Hi, > > if I do a SELECT on a non-existing table, SPI_exec won't return. > I get, e. g. in pgaccess, an error message "
does not exist", > and my code below the function call is never reached. Right, the SPI_exec() call in turn calls the PostgreSQL parser and that raises an elog(ERROR) which longjmp()'s back into the backends main loop waiting for the next client query. > > So why return error codes for SPI_exec when you cannot evaluate them? What do you want here? No error, just an empty result of unspecified format? If the parser cannot determine (due to nonexistance of a table) which datatype the columns of the result set at least should have, what else could he do than trowing an ERROR? > > The background: > > I need to distinguish different client connections within a trigger > function. > To do this, I create a temporary table within a "login" function. > My trigger must check for the existence of this function. > I cannot think of any other method, since there is no "connection id" or > something like that! Unfortunately PL/pgSQL doesn't have global variables. PL/Tcl can have. If you cannot code a part of the login mechanism in PL/Tcl, setting a global variable and returning that in another PL/Tcl function, you could create a temp table with the same name in every connection and fill the connection-ID into that. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com