Re: [PATCHES] Troff -ms output for psql

2005-06-09 Thread Bruce Momjian

Patch applied, thanks.

 Following the commit of my psql latex format fixes, I've re-done the
 patch for the troff-ms format which previously included this patch.
 It's identical to the original but with the latex hunks removed.

---

Roger Leigh wrote:
 Hello,
 
 I've created a patch which adds support for troff -ms output to
 psql.  i.e. \pset format troff-ms.  The patch also corrects some
 problems with the latex format, notably defining an extra column in
 the output table, and correcting some alignment issues; it also
 changes the output to match the border setting as documented in the
 manual page and as shown with the aligned format.
 
 The troff-ms output is mostly identical to the latex output allowing
 for the differences between the two typesetters.
 
 The output should be saved in a file and piped as follows:
 
   cat file | tbl | troff -T ps -ms  file.ps
 or
   tbl file | troff -T ps -ms  file.ps
 
 Because it contains tabs, you'll need to redirect psql output or use
 script, rather than pasting from a terminal window, due to the tabs
 which can be replaced with spaces.
 
 I've attached the patch (against the current mainline), and example
 output of each for each of border=[123] and expanded mode on and off
 (both source and printable copy).
 
 
 Regards,
 Roger
 
 
 PS.  I'm not subscribed, so I would appreciate a CC on any replies.
 Thanks!
 
 
 -- 
 Roger Leigh
 
 Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
 GPG Public Key: 0x25BFB848.  Please sign and encrypt your 
 mail.

Content-Description: patch to add troff output to psql


Content-Description: Troff -ms generated source

[ Attachment, skipping... ]

Content-Description: Troff -ms postscript output

[ Attachment, skipping... ]

Content-Description: LaTeX generated source

[ Attachment, skipping... ]

Content-Description: LaTeX PDF output

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

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

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


Re: [PATCHES] to_timestamp overloaded to convert from Unix epoch

2005-06-09 Thread Bruce Momjian

Updated patch attached with both documentation portions --- applied.

---

Michael Glaesemann wrote:
 Please find attached a patch (diff -c against cvs HEAD) to add a 
 function that accepts a double precision argument assumed to be a Unix 
 epoch timestamp and returns timestamp with time zone, and accompanying 
 documentation.
 
 Usage:
 
 test=# select to_timestamp(200120400);
to_timestamp
 
   1976-05-05 14:00:00+09
 (1 row)
 
 If regression tests are required, I will produce some. I'd appreciate 
 any pointers as to what to look for, as they would be my first attempt 
 at writing regression tests.
 
 Regards
 
 Michael Glaesemann
 grzm myrealbox com
 

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/func.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.252
diff -c -c -r1.252 func.sgml
*** doc/src/sgml/func.sgml  7 Jun 2005 07:08:34 -   1.252
--- doc/src/sgml/func.sgml  9 Jun 2005 16:33:38 -
***
*** 4082,4087 
--- 4082,4094 
  argument is the value to be formatted and the second argument is a
  template that defines the output or input format.
 /para
+para
+ The functionto_timestamp/function function can also take a single 
+ typedouble precision/type argument to convert from Unix epoch to 
+ typetimestamp with time zone/type.
+ (typeInteger/type Unix epochs are implicitly cast to 
+ typedouble precision/type.)
+/para
  
  table id=functions-formatting-table
   titleFormatting Functions/title
***
*** 4139,4144 
--- 4146,4157 
  entryliteralto_timestamp('05nbsp;Decnbsp;2000', 
'DDnbsp;Monnbsp;')/literal/entry
 /row
 row
+ entryliteralfunctionto_timestamp/function(typedouble 
precision/type)/literal/entry
+ entrytypetimestamp with time zone/type/entry
+ entryconvert UNIX epoch to time stamp/entry
+ entryliteralto_timestamp(200120400)/literal/entry
+/row
+row
  entryliteralfunctionto_number/function(typetext/type, 
typetext/type)/literal/entry
  entrytypenumeric/type/entry
  entryconvert string to numeric/entry
Index: src/include/catalog/pg_proc.h
===
RCS file: /cvsroot/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.364
diff -c -c -r1.364 pg_proc.h
*** src/include/catalog/pg_proc.h   7 Jun 2005 07:08:34 -   1.364
--- src/include/catalog/pg_proc.h   9 Jun 2005 16:33:45 -
***
*** 1459,1464 
--- 1459,1466 
  DESCR(greater-than-or-equal);
  DATA(insert OID = 1157 (  timestamptz_gt   PGNSP PGUID 12 f f t f i 2 16 
1184 1184 _null_ _null_ _null_ timestamp_gt - _null_ ));
  DESCR(greater-than);
+ DATA(insert OID = 1158 (  to_timestamp   PGNSP PGUID 14 f f t f i 1 
1184 701 _null_ _null_ _null_ select (\'epoch\'::timestamptz + $1 * \'1 
second\'::interval) - _null_ ));
+ DESCR(convert UNIX epoch to timestamptz);
  DATA(insert OID = 1159 (  timezone   PGNSP PGUID 12 f f t f i 2 
1114 25 1184 _null_ _null_ _null_  timestamptz_zone - _null_ ));
  DESCR(adjust timestamp to new time zone);
  

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

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


Re: [PATCHES] final light versions of Oracle compatibility (SQLSTATE, GREATEST,

2005-06-09 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 Attached is a revised version of this patch. I'll apply it tonight or 
 tomorrow, barring any objections.

I still find the grammar changes to be an ugly kluge --- it should be
possible to do this without introducing bogus nonterminals.

The ns push/pop operations don't appear to be correctly matched
(consider multiple WHEN clauses, a case the regression test does not
cover), nor do they surround the places where the variables are created.
It is likely that you don't need a push/pop at all; if it appears to
work now it's because the end of the block results in a pop and so
the variables disappear then anyway.

The patch is sloppy about whether free_var() is static or not.

I find the proposed change in plpgsql_ns_additem a distinct
disimprovement --- it's dubious even as a micro-optimization
and it certainly hurts legibility.

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] final light versions of Oracle compatibility (SQLSTATE,

2005-06-09 Thread Bruce Momjian

Also, do we want these features?  Do they duplicate anything we already
have?

---

Tom Lane wrote:
 Neil Conway [EMAIL PROTECTED] writes:
  Attached is a revised version of this patch. I'll apply it tonight or 
  tomorrow, barring any objections.
 
 I still find the grammar changes to be an ugly kluge --- it should be
 possible to do this without introducing bogus nonterminals.
 
 The ns push/pop operations don't appear to be correctly matched
 (consider multiple WHEN clauses, a case the regression test does not
 cover), nor do they surround the places where the variables are created.
 It is likely that you don't need a push/pop at all; if it appears to
 work now it's because the end of the block results in a pop and so
 the variables disappear then anyway.
 
 The patch is sloppy about whether free_var() is static or not.
 
 I find the proposed change in plpgsql_ns_additem a distinct
 disimprovement --- it's dubious even as a micro-optimization
 and it certainly hurts legibility.
 
   regards, tom lane
 
 ---(end of broadcast)---
 TIP 6: Have you searched our list archives?
 
http://archives.postgresql.org
 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] [HACKERS] Added schema selection to pg_restore

2005-06-09 Thread Bruce Momjian
Richard van den Berg wrote:
 Since I needed this feature badly, I added the -n / --schema switch to 
 pg_restore. It restores the given schemaname only. It can be used in 
 conjunction with the -t and other switches to make the selection very 
 fine grained.
 
 This patches works for me, but it could use more testing.
 
 Please Cc me in the discussion, as I am not on these lists.
 
 I used the current CVS tree at 
 :pserver:[EMAIL PROTECTED]:/projects/cvsroot as a starting 
 point.

I have applied your patch with minor wording changes --- new version
attached.  It will appear in 8.1.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/pg_restore.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/pg_restore.sgml,v
retrieving revision 1.51
diff -c -c -r1.51 pg_restore.sgml
*** doc/src/sgml/ref/pg_restore.sgml29 May 2005 03:32:18 -  1.51
--- doc/src/sgml/ref/pg_restore.sgml9 Jun 2005 17:55:54 -
***
*** 240,245 
--- 240,257 
   /varlistentry
  
   varlistentry
+   termoption-n replaceable 
class=parameternamespace/replaceable/option/term
+   termoption--schema=replaceable 
class=parameterschema/replaceable/option/term
+   listitem
+para
+ Restore only definitions and/or data in the named schema. Not to be
+ confused with the option-s/option option.  This can be combined 
with
+ option-t/option option.
+/para
+   /listitem
+  /varlistentry
+ 
+  varlistentry
termoption-O/option/term
termoption--no-owner/option/term
listitem
Index: src/bin/pg_dump/pg_backup.h
===
RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.34
diff -c -c -r1.34 pg_backup.h
*** src/bin/pg_dump/pg_backup.h 6 Nov 2004 19:36:01 -   1.34
--- src/bin/pg_dump/pg_backup.h 9 Jun 2005 17:55:55 -
***
*** 98,103 
--- 98,104 
char   *indexNames;
char   *functionNames;
char   *tableNames;
+   char   *schemaNames;
char   *triggerNames;
  
int useDB;
Index: src/bin/pg_dump/pg_backup_archiver.c
===
RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.109
diff -c -c -r1.109 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c17 May 2005 17:30:29 -  
1.109
--- src/bin/pg_dump/pg_backup_archiver.c9 Jun 2005 17:55:56 -
***
*** 1997,2002 
--- 1997,2010 
/* Check if tablename only is wanted */
if (ropt-selTypes)
{
+   if (ropt-schemaNames)
+   {
+   /* If no namespace is specified, it means all. */
+   if (!te-namespace)
+   return 0;
+   if(strcmp(ropt-schemaNames, te-namespace) != 0)
+   return 0;
+   }
if ((strcmp(te-desc, TABLE) == 0) || (strcmp(te-desc, 
TABLE DATA) == 0))
{
if (!ropt-selTable)
Index: src/bin/pg_dump/pg_restore.c
===
RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v
retrieving revision 1.70
diff -c -c -r1.70 pg_restore.c
*** src/bin/pg_dump/pg_restore.c29 Apr 2005 07:08:06 -  1.70
--- src/bin/pg_dump/pg_restore.c9 Jun 2005 17:55:57 -
***
*** 103,108 
--- 103,109 
{no-reconnect, 0, NULL, 'R'},
{port, 1, NULL, 'p'},
{password, 0, NULL, 'W'},
+   {schema, 1, NULL, 'n'},
{schema-only, 0, NULL, 's'},
{superuser, 1, NULL, 'S'},
{table, 1, NULL, 't'},
***
*** 141,147 
}
}
  
!   while ((c = getopt_long(argc, argv, 
acCd:ef:F:h:iI:lL:Op:P:RsS:t:T:uU:vWxX:,
cmdopts, NULL)) != -1)
{
switch (c)
--- 142,148 
}
}
  
!   while ((c = getopt_long(argc, argv, 
acCd:ef:F:h:iI:lL:n:Op:P:RsS:t:T:uU:vWxX:,
cmdopts, NULL)) != -1)
{
switch (c)
***
*** 223,228 
--- 224,234 
opts-tableNames = strdup(optarg);
break;
  
+   case 'n':   /* Dump data for this 
schema only */
+   

[PATCHES] Broken code in recent troff commit

2005-06-09 Thread Tom Lane
print.c line 1009:
fputs(\(rs, fout);

is sufficiently obviously wrong that even my ancient HPUX C compiler is
unhappy.  I don't know troff, though, so I don't know if \\(rs was
meant or something else.

regards, tom lane

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] Broken code in recent troff commit

2005-06-09 Thread Bruce Momjian
Tom Lane wrote:
 print.c line 1009:
 fputs(\(rs, fout);
 
 is sufficiently obviously wrong that even my ancient HPUX C compiler is
 unhappy.  I don't know troff, though, so I don't know if \\(rs was
 meant or something else.

Yea, fixed.  \(rs is reverse slash.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

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

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


Re: [PATCHES] Broken code in recent troff commit

2005-06-09 Thread Roger Leigh
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tom Lane [EMAIL PROTECTED] writes:

 print.c line 1009:
 fputs(\(rs, fout);

 is sufficiently obviously wrong that even my ancient HPUX C compiler is
 unhappy.  I don't know troff, though, so I don't know if \\(rs was
 meant or something else.

Sorry about that.  I'm not sure why GCC didn't pick that up.  Troff
uses \(rs to produce a backslash (Right Slash), so \\(rs will be
correct.  I've double checked the rest of the diff, and that's the
only instance of a missing '\'.


Regards,
Roger

- -- 
Roger Leigh
Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
Debian GNU/Linuxhttp://www.debian.org/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 http://mailcrypt.sourceforge.net/

iD8DBQFCqI6wVcFcaSW/uEgRAvVKAKDLg7ndWV7qoTV3y+Cs8NA2xAXlPQCg9YfQ
OZSJZHnbPTtthHpslRQUf7U=
=cGHq
-END PGP SIGNATURE-

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] PQgetGetCopyData() doc. and PQsendQueryGuts() SegFault handling fix.

2005-06-09 Thread Tom Lane
Volkan YAZICI [EMAIL PROTECTED] writes:
 Fixed PQconsumeInput() usage for PQgetCopyData() in libpq.sgml.
 (Related mail thread:
 http://archives.postgresql.org/pgsql-novice/2005-06/msg00038.php)

 Fixed SegFault in PQsendQueryGuts() when user submitted a binary
 parameter without size.

 And 2 typo fixes.

Applied, thanks.

regards, tom lane

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

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


[PATCHES] fix typo in postmaster.c

2005-06-09 Thread Alvaro Herrera
This trivial patch fixes a typo in StartChildProcess opening comment.
Please apply.

-- 
Alvaro Herrera (alvherre[a]surnet.cl)
Management by consensus: I have decided; you concede.
(Leonard Liu)
Index: postmaster.c
===
RCS file: /home/alvherre/cvs/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.451
diff -c -r1.451 postmaster.c
*** postmaster.c15 May 2005 00:26:18 -  1.451
--- postmaster.c9 Jun 2005 21:50:52 -
***
*** 3414,3420 
  /*
   * StartChildProcess -- start a non-backend child process for the postmaster
   *
!  * xlog determines what kind of child will be started.All child types
   * initially go to BootstrapMain, which will handle common setup.
   *
   * Return value of StartChildProcess is subprocess' PID, or 0 if failed
--- 3414,3420 
  /*
   * StartChildProcess -- start a non-backend child process for the postmaster
   *
!  * xlop determines what kind of child will be started.All child types
   * initially go to BootstrapMain, which will handle common setup.
   *
   * Return value of StartChildProcess is subprocess' PID, or 0 if failed

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] fix typo in postmaster.c

2005-06-09 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes:
 This trivial patch fixes a typo in StartChildProcess opening comment.
 Please apply.

Done.

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] Show full path name when saving in psql

2005-06-09 Thread Bruce Momjian
Greg Sabino Mullane wrote:
[ There is text before PGP section. ]
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 NotDashEscaped: You need GnuPG to verify this message
  
  
 This patch shows the full path name when doing a \s in psql,
 if you have previously issued a \cd command.

I have modified your patch and applied it.  Your patch was missing a
define for dirname in pset, and was missing a pfree when the value
changed.

Attached patch applied.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: src/bin/psql/command.c
===
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.144
diff -c -c -r1.144 command.c
*** src/bin/psql/command.c  9 Jun 2005 15:27:26 -   1.144
--- src/bin/psql/command.c  9 Jun 2005 23:21:16 -
***
*** 276,281 
--- 276,286 
success = false;
}
  
+   if (pset.dirname)
+   pfree(pset.dirname);
+   pset.dirname = pg_strdup(dir);
+   canonicalize_path(pset.dirname);
+ 
if (opt)
free(opt);
}
***
*** 661,667 
success = saveHistory(fname ? fname : /dev/tty);
  
if (success  !quiet  fname)
!   printf(_(Wrote history to file \%s\.\n), fname);
if (!fname)
putchar('\n');
free(fname);
--- 666,673 
success = saveHistory(fname ? fname : /dev/tty);
  
if (success  !quiet  fname)
!   printf(gettext(Wrote history to file \%s/%s\.\n),
!  pset.dirname ? pset.dirname : ., fname);
if (!fname)
putchar('\n');
free(fname);
Index: src/bin/psql/settings.h
===
RCS file: /cvsroot/pgsql/src/bin/psql/settings.h,v
retrieving revision 1.23
diff -c -c -r1.23 settings.h
*** src/bin/psql/settings.h 1 Jan 2005 05:43:08 -   1.23
--- src/bin/psql/settings.h 9 Jun 2005 23:21:16 -
***
*** 49,54 
--- 49,56 
int sversion;   /* backend server 
version */
const char *progname;   /* in case you renamed psql */
char   *inputfile;  /* for error reporting */
+   char   *dirname;/* current directory for \s display */
+ 
unsignedlineno; /* also for error reporting */
  
booltiming; /* enable timing of all queries 
*/

---(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] plperl features

2005-06-09 Thread Bruce Momjian
Sergej Sergeev wrote:
 
 Sergej Sergeev [EMAIL PROTECTED] writes:
   
 
 What happens if you feed other pseudotypes, like cstring or
 language_handler?  Shouldn't that be disallowed or something?
   
 
 
   
 
 Other pseudo-types are disallowed (no-change)
 
 
 
 No, because you diked out the check at lines 1452ff, rather than
 upgrading it to something correct.
 
 I find the fn_retispseudo and arg_is_p flags pretty bogus anyway
 since they fail to indicate *which* pseudotype it is.  You might as
 well just test for the specific type OID.
 
  regards, tom lane
   
 
 New patch. I have added the check pseudo-type argumetns.
 Specific type is substituted in runtime, during function call.

I can't apply this patch because the code has changed too much.  Would
you regenerate a patch against current CVS?

Also, this indenting seems wrong:

 ! /* Disallow pseudotype argument, except 
 ANYELEMENT or ANYARRAY */
   if (typeStruct-typtype == 'p')
 + if (procStruct-proargtypes[i] == 
 ANYARRAYOID ||
 + procStruct-proargtypes[i] == 
 ANYELEMENTOID)
 +  /* okay */
 + prodesc-arg_is_p[i] = true;
 + else
   {
   free(prodesc-proname);
   free(prodesc);

Putting an 'if' after an 'if' is just too strange.  Please make a more
complete fix that has proper block indenting.

Also, I don't think the arg_is_p variable is really the proper fix for
this, but I am unsure what to recomment.  Others?

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

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

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


Re: [PATCHES] final light versions of Oracle compatibility (SQLSTATE,

2005-06-09 Thread Neil Conway

Tom Lane wrote:

I still find the grammar changes to be an ugly kluge --- it should be
possible to do this without introducing bogus nonterminals.


The scope-local variables need to be added to the namespace by the time 
that we parse the WHEN clauses. I can see two ways to do that: adding a 
bogus non-terminal, or using a mid-rule action. Mid-rule actions are 
pretty ugly, though. Is there a better alternative?



The ns push/pop operations don't appear to be correctly matched


Sorry, asleep at the switch -- the ns_push/pop stuff isn't even needed, 
it was from an early revision of the patch.


A revised patch is attached -- once the nonterminal stuff is sorted I'll 
apply it.


-Neil
Index: doc/src/sgml/plpgsql.sgml
===
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/plpgsql.sgml,v
retrieving revision 1.70
diff -c -r1.70 plpgsql.sgml
*** doc/src/sgml/plpgsql.sgml	7 Jun 2005 02:47:15 -	1.70
--- doc/src/sgml/plpgsql.sgml	10 Jun 2005 01:22:04 -
***
*** 2110,2115 
--- 2110,2126 
don't use literalEXCEPTION/ without need.
   /para
  /tip
+ 
+ para
+  Within an exception handler, the varnameSQLSTATE/varname
+  variable contains the error code that corresponds to the
+  exception that was raised (refer to xref
+  linkend=errcodes-table for a list of possible error
+  codes). The varnameSQLERRM/varname variable contains the
+  error message associated with the exception. These variables are
+  undefined outside exception handlers.
+ /para
+ 
  example id=plpgsql-upsert-example
  titleExceptions with UPDATE/INSERT/title
  para
Index: src/backend/utils/error/elog.c
===
RCS file: /var/lib/cvs/pgsql/src/backend/utils/error/elog.c,v
retrieving revision 1.159
diff -c -r1.159 elog.c
*** src/backend/utils/error/elog.c	9 Jun 2005 22:29:52 -	1.159
--- src/backend/utils/error/elog.c	10 Jun 2005 01:22:04 -
***
*** 1482,1487 
--- 1482,1507 
  	}
  }
  
+ /*
+  * Unpack MAKE_SQLSTATE code. Note that this returns a pointer to a
+  * static buffer.
+  */
+ char *
+ unpack_sql_state(int sql_state)
+ {
+ 	static char	buf[12];
+ 	int			i;
+ 
+ 	for (i = 0; i  5; i++)
+ 	{
+ 		buf[i] = PGUNSIXBIT(sql_state);
+ 		sql_state = 6;
+ 	}
+ 
+ 	buf[i] = '\0';
+ 	return buf;
+ }
+ 
  
  /*
   * Write error report to server's log
***
*** 1497,1517 
  	appendStringInfo(buf, %s:  , error_severity(edata-elevel));
  
  	if (Log_error_verbosity = PGERROR_VERBOSE)
! 	{
! 		/* unpack MAKE_SQLSTATE code */
! 		char		tbuf[12];
! 		int			ssval;
! 		int			i;
! 
! 		ssval = edata-sqlerrcode;
! 		for (i = 0; i  5; i++)
! 		{
! 			tbuf[i] = PGUNSIXBIT(ssval);
! 			ssval = 6;
! 		}
! 		tbuf[i] = '\0';
! 		appendStringInfo(buf, %s: , tbuf);
! 	}
  
  	if (edata-message)
  		append_with_tabs(buf, edata-message);
--- 1517,1523 
  	appendStringInfo(buf, %s:  , error_severity(edata-elevel));
  
  	if (Log_error_verbosity = PGERROR_VERBOSE)
! 		appendStringInfo(buf, %s: , unpack_sql_state(edata-sqlerrcode));
  
  	if (edata-message)
  		append_with_tabs(buf, edata-message);
Index: src/include/utils/elog.h
===
RCS file: /var/lib/cvs/pgsql/src/include/utils/elog.h,v
retrieving revision 1.78
diff -c -r1.78 elog.h
*** src/include/utils/elog.h	31 Dec 2004 22:03:46 -	1.78
--- src/include/utils/elog.h	10 Jun 2005 01:22:04 -
***
*** 282,287 
--- 282,288 
  
  /* Other exported functions */
  extern void DebugFileOpen(void);
+ extern char *unpack_sql_state(int sql_state);
  
  /*
   * Write errors to stderr (or by equal means when stderr is
Index: src/pl/plpgsql/src/gram.y
===
RCS file: /var/lib/cvs/pgsql/src/pl/plpgsql/src/gram.y,v
retrieving revision 1.74
diff -c -r1.74 gram.y
*** src/pl/plpgsql/src/gram.y	8 Jun 2005 00:49:36 -	1.74
--- src/pl/plpgsql/src/gram.y	10 Jun 2005 01:22:04 -
***
*** 92,97 
--- 92,98 
  		PLpgSQL_stmt_block		*program;
  		PLpgSQL_condition		*condition;
  		PLpgSQL_exception		*exception;
+ 		PLpgSQL_exception_block	*exception_block;
  		PLpgSQL_nsitem			*nsitem;
  		PLpgSQL_diag_item		*diagitem;
  }
***
*** 129,137 
  %type stmt	stmt_dynexecute stmt_getdiag
  %type stmt	stmt_open stmt_fetch stmt_close stmt_null
  
! %type list	exception_sect proc_exceptions
  %type exception	proc_exception
  %type condition	proc_conditions
  
  %type list	raise_params
  %type ival	raise_level raise_param
--- 130,140 
  %type stmt	stmt_dynexecute stmt_getdiag
  %type stmt	stmt_open stmt_fetch stmt_close stmt_null
  
! %type list	proc_exceptions
! %type exception_block exception_sect
  %type exception	proc_exception
  %type condition	proc_conditions
+ %type variable		sqlstate_var sqlerrm_var
  
  %type 

Re: [PATCHES] plperl features

2005-06-09 Thread Tom Lane
Bruce Momjian pgman@candle.pha.pa.us writes:
 Also, I don't think the arg_is_p variable is really the proper fix for
 this, but I am unsure what to recomment.  Others?

The thing I didn't like about that was that it assumes there is only
one pseudotype behavior that is or ever will be interesting for plperl.

I think it'd probably make more sense to store an array of the parameter
type OIDs and then check for ANYELEMENT or ANYARRAY as such in the
places where the patch uses arg_is_p.

regards, tom lane

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] [HACKERS] PGPASSWORD and client tools

2005-06-09 Thread Tom Lane
Bruce Momjian pgman@candle.pha.pa.us writes:
   charpgpassfile[MAXPGPATH];

 ! if (!pgpassfile)
 ! {
 ! fprintf(stderr, libpq_gettext(out of memory\n));
 ! return NULL;
 ! }

Waste of code, eh?

regards, tom lane

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [PATCHES] [HACKERS] PGPASSWORD and client tools

2005-06-09 Thread Bruce Momjian
Tom Lane wrote:
 Bruce Momjian pgman@candle.pha.pa.us writes:
  charpgpassfile[MAXPGPATH];
 
  !   if (!pgpassfile)
  !   {
  !   fprintf(stderr, libpq_gettext(out of memory\n));
  !   return NULL;
  !   }
 
 Waste of code, eh?

Never hurts to be too careful.  (removed)  ;-)

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly