Re: [PATCHES] [PATCH] Clarify issues with SPI and C language function limitations

2005-08-14 Thread Martijn van Oosterhout
On Sat, Aug 13, 2005 at 06:27:29PM -0400, Tom Lane wrote:
 Martijn van Oosterhout kleptog@svana.org writes:
  The second clarifies when the get_fn_expr_rettype() and
  get_fn_expr_argtype() functions can actually provide the information
  requested.
 
 Except it doesn't actually tell you anything very definite ...

Well, that's because it isn't. If you call a type input function
explicitly as part of a query then the info will be available. If
someone uses your function by calling DirectFunctionCall or
OidFunctionCall then the information isn't available.

You can't be definite since it is caller who decides, the person
writing the function can't know.

Given that OidFunctionCall is not mentioned in the documentation
currently, I figured that using it here to describe why these calls
won't work would be a waste of time given people won't know what it
means anyway. Hence the vagueness.

I would favour adding the return type and arg types to FmgrInfo,
because that's nearly always available (except when using
DirectFunctionCall). Still no guarentee, but better. It means I
wouldn't need to create a dummy flinfo-fn_expr when calling a
polymorphic function from C.

I just feel this whole mess needs to be documented *somewhere*, I'm
just not sure where...

Have a nice day,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
 tool for doing 5% of the work and then sitting around waiting for someone
 else to do the other 95% so you can sue them.


pgpEL4x5IxAWC.pgp
Description: PGP signature


[PATCHES] [PATCH] Clarify issues with SPI and C language function limitations

2005-08-13 Thread Martijn van Oosterhout
[Please CC any replies]

Hi,

Here is a patch to the documentation clarifying some minor issues. 

The first is to the main SPI documentation clarifying that SPI isn't
available unless there is a current snapshot (leading to the no
snapshot has been set error).

The second clarifies when the get_fn_expr_rettype() and
get_fn_expr_argtype() functions can actually provide the information
requested.

Have a nice day,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
 tool for doing 5% of the work and then sitting around waiting for someone
 else to do the other 95% so you can sue them.
Index: doc/src/sgml/spi.sgml
===
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/spi.sgml,v
retrieving revision 1.42
diff -u -r1.42 spi.sgml
--- doc/src/sgml/spi.sgml   29 Jul 2005 13:00:03 -  1.42
+++ doc/src/sgml/spi.sgml   13 Aug 2005 19:10:54 -
@@ -29,6 +29,14 @@
   /para
  /note
 
+ note
+  para
+   SPI can not be used in functions called prior to the start of query
+   execution because there is no current snapshot at that point. Examples of
+   this include type input functions and cost estimation functions.
+  /para
+ /note
+
  para
   To avoid misunderstanding we'll use the term quotefunction/quote
   when we speak of acronymSPI/acronym interface functions and
Index: doc/src/sgml/xfunc.sgml
===
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v
retrieving revision 1.103
diff -u -r1.103 xfunc.sgml
--- doc/src/sgml/xfunc.sgml 30 May 2005 23:09:07 -  1.103
+++ doc/src/sgml/xfunc.sgml 13 Aug 2005 19:10:55 -
@@ -2778,6 +2778,16 @@
  as an alternative to functionget_fn_expr_rettype/.
 /para
 
+footnote
+ para
+  Information about argument and return types is generally available if
+  you are executing a normal function within a normal query. However, it
+  can be missing for implicitly used functions, such as type
+  input/output functions that are called directly by the planner before
+  the query starts.
+ /para
+/footnote
+
 para
  For example, suppose we want to write a function to accept a single
  element of any type, and return a one-dimensional array of that type:


pgp96sslT5d75.pgp
Description: PGP signature


Re: [PATCHES] [PATCH] Clarify issues with SPI and C language function limitations

2005-08-13 Thread Tom Lane
Martijn van Oosterhout kleptog@svana.org writes:
 Here is a patch to the documentation clarifying some minor issues.=20

 The first is to the main SPI documentation clarifying that SPI isn't
 available unless there is a current snapshot (leading to the no
 snapshot has been set error).

This is wrong.

 The second clarifies when the get_fn_expr_rettype() and
 get_fn_expr_argtype() functions can actually provide the information
 requested.

Except it doesn't actually tell you anything very definite ...

regards, tom lane

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq