Re: [PATCHES] Some new SPI functions

2004-02-15 Thread Thomas Hallgren
 Who did you think would do it?

 regards, tom lane

you :-)

Seriously, I didn't give it much though. This is undoubtedly the best way
although some projects handle it differently. A  tech-writer perhaps, with
better writing skills then programmers in general. But people like that are
probabaly not too common in the open source field. If you don't do like
JBoss and charge for the docs (I'm *not* in favor of that).

Anyway, here's the patch again. This time with documentation.

Index: doc/src/sgml/spi.sgml
===
retrieving revision 1.30
diff -u -r1.30 spi.sgml
--- doc/src/sgml/spi.sgml 1 Dec 2003 22:07:57 - 1.30
+++ doc/src/sgml/spi.sgml 15 Feb 2004 13:47:13 -
@@ -573,6 +573,190 @@

 !-- *** --

+refentry id=spi-spi-getargcount
+ refmeta
+  refentrytitleSPI_getargcount/refentrytitle
+ /refmeta
+
+ refnamediv
+  refnameSPI_getargcount/refname
+  refpurposereturns the number of arguments needed when executing a plan
+  prepared by functionSPI_prepare/function/refpurpose
+ /refnamediv
+
+ indextermprimarySPI_getargcount/primary/indexterm
+
+ refsynopsisdiv
+synopsis
+int SPI_getargcount(void * parameterplan/parameter)
+/synopsis
+ /refsynopsisdiv
+
+ refsect1
+  titleDescription/title
+
+  para
+   functionSPI_getargcount/function returns the number of arguments
needed
+   when executing a plan prepared by functionSPI_prepare/function.
+  /para
+ /refsect1
+
+ refsect1
+  titleArguments/title
+
+  variablelist
+   varlistentry
+termliteralvoid * parameterplan/parameter/literal/term
+listitem
+ para
+  execution plan (returned by functionSPI_prepare/function)
+ /para
+/listitem
+   /varlistentry
+  /variablelist
+ /refsect1
+
+ refsect1
+  titleReturn Value/title
+  para
+The expected argument count for the parameterplan/parameter or
+symbolSPI_ERROR_ARGUMENT/symbol if the parameterplan
+/parameter is symbolNULL/symbol
+  /para
+ /refsect1
+/refentry
+
+!-- *** --
+
+refentry id=spi-spi-getargtypeid
+ refmeta
+  refentrytitleSPI_getargtypeid/refentrytitle
+ /refmeta
+
+ refnamediv
+  refnameSPI_getargtypeid/refname
+  refpurposereturns the expected typeid for the specified argument when
+  executing a plan prepared by
functionSPI_prepare/function/refpurpose
+ /refnamediv
+
+ indextermprimarySPI_getargtypeid/primary/indexterm
+
+ refsynopsisdiv
+synopsis
+Oid SPI_getargtypeid(void * parameterplan/parameter, int
parameterargIndex/parameter)
+/synopsis
+ /refsynopsisdiv
+
+ refsect1
+  titleDescription/title
+
+  para
+   functionSPI_getargtypeid/function returns the Oid representing the
type
+   id for argument at parameterargIndex/parameter in a plan prepared by
+   functionSPI_prepare/function. First argument is at index zero.
+  /para
+ /refsect1
+
+ refsect1
+  titleArguments/title
+
+  variablelist
+   varlistentry
+termliteralvoid * parameterplan/parameter/literal/term
+listitem
+ para
+  execution plan (returned by functionSPI_prepare/function)
+ /para
+/listitem
+   /varlistentry
+
+   varlistentry
+termliteralint parameterargIndex/parameter/literal/term
+listitem
+ para
+  zero based index of the argument
+ /para
+/listitem
+   /varlistentry
+  /variablelist
+ /refsect1
+
+ refsect1
+  titleReturn Value/title
+  para
+The type id of the argument at the given index or symbol
+SPI_ERROR_ARGUMENT/symbol if the parameterplan/parameter is
+symbolNULL/symbol or parameterargIndex/parameter is less than 0
or
+not less than the number of arguments declared for the parameterplan
+/parameter
+  /para
+ /refsect1
+/refentry
+
+!-- *** --
+
+refentry id=spi-spi-is_cursor_plan
+ refmeta
+  refentrytitleSPI_is_cursor_plan/refentrytitle
+ /refmeta
+
+ refnamediv
+  refnameSPI_is_cursor_plan/refname
+  refpurposereturns symboltrue/symbol if a plan
+  prepared by functionSPI_prepare/function can be passed
+  as an argument to functionSPI_cursor_open/function/refpurpose
+ /refnamediv
+
+ indextermprimarySPI_is_cursor_plan/primary/indexterm
+
+ refsynopsisdiv
+synopsis
+bool SPI_is_cursor_plan(void * parameterplan/parameter)
+/synopsis
+ /refsynopsisdiv
+
+ refsect1
+  titleDescription/title
+
+  para
+   functionSPI_is_cursor_plan/function returns symboltrue/symbol
+   if a plan prepared by functionSPI_prepare/function can be passed
+   as an argument to functionSPI_cursor_open/function and symbol
+   false/symbol if that is not the case. The criteria is that the
+   parameterplan/parameter represents one single command and that this
+   command is a commandSELECT/command without an
commandINTO/command
+   clause.
+  /para
+ /refsect1
+
+ refsect1
+  titleArguments/title
+
+  variablelist
+   varlistentry
+termliteralvoid * parameterplan/parameter/literal/term
+listitem
+ para
+  execution plan (returned 

Re: [PATCHES] Afrikaans translation of libpq

2004-02-15 Thread Peter Eisentraut
Petri Jooste wrote:
 I started a new translation of postgresql into Afrikaans (af_ZA).
 Attached is the file libpq.po

 Please also make sure that Afrikaans is added to the right nls.mk
 file.

Installed into head branch.  If you want this in the 7.4 branch as well, 
let me know.  (That would be useful only if you plan to provide more 
translations for the 7.4 branch soon.)

Btw., you don't need to send the *.mo files.  They are 
platform-dependent.


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [PATCHES] [HACKERS] dollar quoting

2004-02-15 Thread Andrew Dunstan


Tom Lane wrote:

Andrew Dunstan [EMAIL PROTECTED] writes:
 

Tom Lane wrote:
   

... But how about
42$foo$
This is a syntax error in 7.4, and we propose to redefine it as an
integer literal '42' followed by a dollar-quote start symbol.
 

 

The test should not succeed anywhere in the string '42$foo$'.
   

No, it won't.  The problem is that it should, because the backend will
see that as '42' followed by a $foo$ quote start.
Ok, I see what you are saying. This mismatch would only happen on 
invalid input, though. I believe that what I did will work on all legal 
input.

I think that this might be cured by having psql recognise a legal 
identifier or keyword and eating it as a word, rather than treating it 
as just another set of bytes in the stream. That would enable us to 
avoid the lookback in the dollar-quote recognition test altogether. The 
attached patch does it that way - the keyword/id test needs to come 
right at the end of the loop to avoid clashing with backslash commands, 
btw.

I *think* that this way psql will recognise the start of a dollar quote 
iff the backend lexer would.

 

Interacting with lexer states would probably be ... unpleasant. Matching 
a stream oriented lexer with a line oriented CLI would be messy I suspect.
   

I think it would not be that bad.  We'd have to run the lexer on the
command input buffer and see what state it terminates in.
 

Yeah. I am not enough of a flex wizard to undertake the task, though. It 
would take me lots of time. If we make a decision that we really need 
this in order to do dollar quoting in psql I would need some substantial 
help, at least.

cheers

andrew
Index: src/bin/psql/mainloop.c
===
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/mainloop.c,v
retrieving revision 1.61
diff -c -r1.61 mainloop.c
*** src/bin/psql/mainloop.c 25 Jan 2004 03:07:22 -  1.61
--- src/bin/psql/mainloop.c 15 Feb 2004 14:28:02 -
***
*** 21,26 
--- 21,61 
  sigjmp_bufmain_loop_jmp;
  #endif
  
+ /*
+  * function to detect a valid $foo$ quote delimiter at the start of the
+  * parameter dquote.
+  */
+ 
+ static bool valid_dolquote(char * dquote)
+ {
+   int i;
+ 
+   /* must start with a $ */
+   if (dquote[0] != '$')
+   return false;
+ 
+   /* empty 'identifier' case */
+   if (dquote[1] == '$')
+   return true;
+ 
+   /* first 'identifier' char must be a letter or have high bit set */
+   if (!isalpha(dquote[1])  (dquote[1]  0x80) == 0)
+   return false;
+ 
+   /* subsequent chars must be alphanumeric or _ or have high bit set */
+   for (i = 2; dquote[i] != '$'; i++)
+   {
+   if ((dquote[i]  0x80) == 0  ! isalnum(dquote[i]) 
+   dquote[i] != '_')
+   {
+   /* we found an invalid character */
+   return false;
+   }
+   }
+ 
+   return true;
+ }
+ 
  
  /*
   * Main processing loop for reading lines of input
***
*** 49,54 
--- 84,92 
unsigned int query_start;
volatile int count_eof = 0;
volatile unsigned int bslash_count = 0;
+   volatile bool free_dolquote = false;
+   char *dol_quote = NULL;
+ 
  
int i,
prevlen,
***
*** 120,125 
--- 158,164 
in_quote = 0;
paren_level = 0;
count_eof = 0;
+   free_dolquote = true;
slashCmdStatus = CMD_UNKNOWN;
}
else
***
*** 136,141 
--- 175,190 
pqsignal(SIGINT, handle_sigint);/* control-C = cancel 
*/
  #endif   /* not WIN32 */
  
+   if (free_dolquote)
+   {
+   if(dol_quote)
+   {
+   free(dol_quote);
+   dol_quote = NULL;
+   }
+   free_dolquote = false;
+   }
+ 
fflush(stdout);
  
if (slashCmdStatus == CMD_NEWEDIT)
***
*** 150,155 
--- 199,209 
in_xcomment = 0;
in_quote = 0;
paren_level = 0;
+   if(dol_quote)
+   {
+   free(dol_quote);
+   dol_quote = NULL;
+   }
slashCmdStatus = CMD_UNKNOWN;
}
  
***
*** 161,167 
{
int prompt_status;
  
!   if (in_quote  in_quote == '\'')