Re: [PATCHES] dbsize backend integration

2005-06-14 Thread Andreas Pflug

Bruce Momjian wrote:

Andreas Pflug wrote:

As a start for a bunch of instrumentation functions that should be 
included in the backend as discussed previously, here are the dbsize 
functions. The dbsize.c file should go to the usual place, 
src/backend/utils/adt.



How does this related to /contrib/dbsize?  You have moved some
functions, but not recreated others.



This patch includes only those functions that return the basic values 
nobody but the server can provide; all others are some kind of derived 
functions, as implemented by some personal needs. They should stay in 
contrib, as they all have some limitations (e.g. implementing a subset, 
as relation_size which only counts tables, or total_relation_size et al, 
which are schema ignorant).


Regards,
Andreas

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

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


Re: [PATCHES] uptime function to postmaster

2005-06-14 Thread Neil Conway

Bruce Momjian wrote:

We need to preceed our function names with pg_ for cases like this where
we are supplying pg-specific behavior.


We do? I'm not sure I can see much of a consistent naming convention for 
functions like these: version(), obj_description(), has_xyz_privilege(), 
format_type(), set_config(), and the like are surely "pg-specific", for 
example.


-Neil

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


[PATCHES] Add PG version number to NLS files

2005-06-14 Thread Bruce Momjian

I have developed the following patch which adds PG_VERSION to the end of
language-specific file names.  I used it for libpq too, rather than the
SONAME, because the language strings might change between versions while
the API/SONAME might not.

Would someone who uses NLS please test this?  Thanks.

---

Bruce Momjian wrote:
> 
> Is this a direction we want to explore --- using the SONAME as part of
> the translation domain?
> 
> ---
> 
> Martin Pitt wrote:
> -- Start of PGP signed section.
> > Hi!
> > 
> > Bruce Momjian [2005-02-09 18:05 -0500]:
> > > > However, I just stumbled across another problem: libpq3 and the new
> > > > libpq4 use the same translation domain "libpq4", thus they cannot be
> > > > installed in parallel. Can you please change the domain to "libpq4" as
> > > > well? This should generally be done anyway, but at least we can live
> > > > with one breakage of this rule (for libpq3), so that we don't need to
> > > > mess with the old libpq3 package.
> > > 
> > > Uh, what is the translation domain?
> > 
> > In short, that is the unique name for a bunch of translations for a
> > particular application or group of related applications. The key point
> > is that the name of the file in
> > /usr/share/locale//LC_MESSAGES/.mo and the call 
> > 
> >   bindtextdomain ("", NULL)
> > 
> > must use the same  so that libintl can find the mo file.
> > However, that means that all applications that are installed in
> > parallel need a distinct domain. Since the whole point of SONAMes is
> > to allow several different library API versions to be installed in
> > parallel, every library API (i. e. SONAME) should have an unique
> > domain, which can be achieved easiest by just appending the SONAME to
> > the translation domain.
> > 
> > In my test packages I used the following patch:
> > 
> > diff -ruN postgresql-8.0.1-old/src/interfaces/libpq/fe-misc.c 
> > postgresql-8.0.1/src/interfaces/libpq/fe-misc.c
> > --- postgresql-8.0.1-old/src/interfaces/libpq/fe-misc.c 2004-12-31 
> > 23:03:50.0 +0100
> > +++ postgresql-8.0.1/src/interfaces/libpq/fe-misc.c 2005-02-07 
> > 22:55:13.177419296 +0100
> > @@ -1133,7 +1133,7 @@
> > {
> > already_bound = 1;
> > /* No relocatable lookup here because the binary could be 
> > anywhere */
> > -   bindtextdomain("libpq", getenv("PGLOCALEDIR") ? 
> > getenv("PGLOCALEDIR") : LOCALEDIR);
> > +   bindtextdomain("libpq4", getenv("PGLOCALEDIR") ? 
> > getenv("PGLOCALEDIR") : LOCALEDIR);
> > }
> > 
> > return dgettext("libpq", msgid);
> > diff -ruN postgresql-8.0.1-old/src/interfaces/libpq/nls.mk 
> > postgresql-8.0.1/src/interfaces/libpq/nls.mk
> > --- postgresql-8.0.1-old/src/interfaces/libpq/nls.mk2005-01-14 
> > 09:57:06.0 +0100
> > +++ postgresql-8.0.1/src/interfaces/libpq/nls.mk2005-02-07 
> > 22:54:54.770217616 +0100
> > @@ -1,5 +1,5 @@
> >  # $PostgreSQL: pgsql/src/interfaces/libpq/nls.mk,v 1.20 2005/01/14 
> > 08:57:06 petere Exp $
> > -CATALOG_NAME   := libpq
> > +CATALOG_NAME   := libpq4
> >  AVAIL_LANGUAGES:= af cs de es fr hr it ko nb pl pt_BR ru sk sl sv 
> > tr zh_CN zh_TW
> >  GETTEXT_FILES  := fe-auth.c fe-connect.c fe-exec.c fe-lobj.c fe-misc.c 
> > fe-protocol2.c fe-protocol3.c fe-secure.c
> >  GETTEXT_TRIGGERS:= libpq_gettext pqInternalNotice:2
> > 
> > Compared to the SONAME, changing the translation domain is relatively
> > uncritical, so if you don't want to change this upstream, I can
> > maintain this patch for Debian/Ubuntu. However, I heard that some RPM
> > guys plan a infrastructure similar to mine, and at that point they
> > will have precisely the same problems :-)
> > 
> > Thanks for considering and have a nice day!
> > 
> > Martin
> > -- 
> > Martin Pitt   http://www.piware.de
> > Ubuntu Developerhttp://www.ubuntulinux.org
> > Debian GNU/Linux Developer   http://www.debian.org
> -- End of PGP section, PGP failed!
> 
> -- 
>   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
> 

-- 
  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/nls-global.mk
==

Re: [PATCHES] [HACKERS] Should *.backup files ever be removed from pg_xlog?

2005-06-14 Thread Bruce Momjian

Applied.  (Thanks (to me).  :-))

---

Bruce Momjian wrote:
> Bruce Momjian wrote:
> > Tom Lane wrote:
> > > Bruce Momjian  writes:
> > > > I have fixed the code to properly remove *.backup files from the
> > > > /pg_xlog directory once they are archived.
> > > 
> > > I do not actually think that this is a good idea.  The .backup files are
> > > not large and they are pretty critical info --- so having multiple
> > > copies of them seems like a good idea.  We don't auto-remove timeline
> > > history files either, for the same reason.
> > 
> > I realize the files are small, but the number of entries in the
> > directory might get pretty large.  I am also worried about folks
> > realizing we are not cleaning out those directories and mucking in there
> > when they shouldn't --- I already got a private email asking why there
> > are so many files in there and can they be cleared out.  In fact, the
> > archive_status/ directory also keeps *.done files for the backup files.
> > 
> > We knowe we have archived the *.backup files.  Are these files any use
> > if we can't get the archive files restored?
> > 
> > OK, how about if we do this cleanup when we do pg_stop_backup() so we
> > delete any previous *.backup files, rather than do it as part of
> > checkpoint.
> 
> OK, new version that removes old backup files only when pg_stop_backup()
> is run.  This way the current backup file will always be in pg_xlog/.
> 
> -- 
>   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/backend/access/transam/xlog.c
> ===
> RCS file: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v
> retrieving revision 1.198
> diff -c -c -r1.198 xlog.c
> *** src/backend/access/transam/xlog.c 8 Jun 2005 15:50:26 -   1.198
> --- src/backend/access/transam/xlog.c 9 Jun 2005 14:52:11 -
> ***
> *** 450,455 
> --- 450,456 
>   static int  PreallocXlogFiles(XLogRecPtr endptr);
>   static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
>   int *nsegsremoved, int 
> *nsegsrecycled);
> + static void RemoveOldBackupHistory(void);
>   static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode);
>   static bool ValidXLOGHeader(XLogPageHeader hdr, int emode);
>   static XLogRecord *ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt);
> ***
> *** 2356,2361 
> --- 2357,2417 
>   }
>   
>   /*
> +  * Remove previous backup history files
> +  */
> + static void
> + RemoveOldBackupHistory(void)
> + {
> + DIR*xldir;
> + struct dirent *xlde;
> + charpath[MAXPGPATH];
> + 
> + xldir = AllocateDir(XLogDir);
> + if (xldir == NULL)
> + ereport(ERROR,
> + (errcode_for_file_access(),
> + errmsg("could not open transaction log directory 
> \"%s\": %m",
> +XLogDir)));
> + 
> + errno = 0;
> + while ((xlde = readdir(xldir)) != NULL)
> + {
> + if (strlen(xlde->d_name) > 24 &&
> + strspn(xlde->d_name, "0123456789ABCDEF") == 24 &&
> + strcmp(xlde->d_name + strlen(xlde->d_name) - 
> strlen(".backup"),
> +".backup") == 0)
> + {
> + /* Remove any *.backup files that have been archived. */
> + if (!XLogArchivingActive() || 
> XLogArchiveIsDone(xlde->d_name))
> + {
> + ereport(DEBUG2,
> +   (errmsg("removing transaction log 
> backup history file \"%s\"",
> +   xlde->d_name)));
> + snprintf(path, MAXPGPATH, "%s/%s", XLogDir, 
> xlde->d_name);
> + unlink(path);
> + XLogArchiveCleanup(xlde->d_name);
> + }
> + }
> + errno = 0;
> + }
> + #ifdef WIN32
> + 
> + /*
> +  * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
> +  * not in released version
> +  */
> + if (GetLastError() == ERROR_NO_MORE_FILES)
> + errno = 0;
> + #endif
> + if (errno)
> + ereport(ERROR,
> + (errcode_for_file_access(),
> + errmsg("could not read transaction log directory 
> \"%s\": %m",
> +XLogDir)));
> + FreeDir(xldir);
> + }
> + 
> + /*
>* Restore the backup blocks present in an XLOG record, if any.
>*
>* We assume all of the reco

Re: [PATCHES] dbsize backend integration

2005-06-14 Thread Bruce Momjian
Andreas Pflug wrote:
> As a start for a bunch of instrumentation functions that should be 
> included in the backend as discussed previously, here are the dbsize 
> functions. The dbsize.c file should go to the usual place, 
> src/backend/utils/adt.

How does this related to /contrib/dbsize?  You have moved some
functions, but not recreated 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 4: Don't 'kill -9' the postmaster


Re: [PATCHES] plperl: enable UTF-8 support

2005-06-14 Thread Bruce Momjian

Newest patch applied.  Thanks.

---

Bruce Momjian wrote:
> 
> It seems the plperl code has changed in the areas you are modifying. 
> Would you update your patch against current CVS?  Thanks.
> 
> ---
> 
> David Kamholz wrote:
> > Hello,
> > 
> > Here's a patch I added against plperl, originally against beta5, now 
> > against rc1. It simply checks with GetDatabaseEncoding() if the current 
> > database is in UTF-8, and if so, sets the UTF-8 flag on the arguments 
> > that are passed to perl. This means that it isn't necessary to 
> > utf8::upgrade() every string, as perl has no way of knowing offhand 
> > that a string is UTF-8 -- but postgres does, because the database 
> > encoding is specified, so it makes sense to turn the flag on. You 
> > should also be able to properly manipulate UTF-8 strings now from 
> > plperl as opposed to plperlu, because otherwise you'd have to use 
> > encoding 'utf8' which was not allowed. It could also eliminate some 
> > unexpected bugs if you assume that perl knows the string is unicode. It 
> > is enabled only for perl 5.6 and higher, so earlier versions will not 
> > be affected.
> > 
> > I have been assured by crab that the patch is quite harmless and will 
> > not break anything. It would be great to see it in 8 final! :-)
> > 
> > Regards,
> > Dave
> > 
> 
> [ Attachment, skipping... ]
> 
> > 
> > ---(end of broadcast)---
> > TIP 4: Don't 'kill -9' the postmaster
> 
> -- 
>   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
> 

-- 
  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 4: Don't 'kill -9' the postmaster


Re: [PATCHES] AT TIME ZONE with full timezones

2005-06-14 Thread Bruce Momjian

Patch applied.  Thanks.  Doc updates applied too.

---


Magnus Hagander wrote:
> This patch makes it possible to use the full set of timezones when doing
> "AT TIME ZONE", and not just the shorlist previously available. For
> example:
> 
> SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London';
> 
> works fine now. It will also obey whatever DST rules were in effect at
> just that date, which the previous implementation did not.
> 
> It also supports the AT TIME ZONE on the timetz datatype. The whole
> handling of DST is a bit bogus there, so I chose to make it use whatever
> DST rules are in effect at the time of executig the query. not sure if
> anybody is actuallyi *using* timetz though, it seems pretty
> unpredictable just because of this...
> 
> Docs updates forthcoming assuming this approach is considered good ;-)
> 
> //Magnus

Content-Description: timezones.patch

[ Attachment, skipping... ]

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

-- 
  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 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] Unicode characters above 0x10000 #2

2005-06-14 Thread Bruce Momjian

Patch applied.  Thanks.

---


John Hansen wrote:
> Bruce,
> 
> Attached patch replaces the original, applied today against CVS HEAD.
> Fixes the surrogates, and limits to 4 byte utf8 as per spec.
> 
> Also extends UtfToLocal to 4 byte characters (tho, it does not add any,
> just enables the code to handle them. If my interpretation of this code
> is wrong, please let me know, and correct it).
> 
> ... John
> 
> > -Original Message-
> > From: Bruce Momjian [mailto:[EMAIL PROTECTED] 
> > Sent: Sunday, June 05, 2005 11:23 AM
> > To: pgman@candle.pha.pa.us
> > Cc: John Hansen; pgsql-hackers@postgresql.org; PostgreSQL-patches
> > Subject: Re: [PATCHES] Unicode characters above 0x1 #2
> > 
> > 
> > Your patch has been added to the PostgreSQL unapplied patches list at:
> > 
> > http://momjian.postgresql.org/cgi-bin/pgpatches
> > 
> > It will be applied as soon as one of the PostgreSQL 
> > committers reviews and approves it.
> > 
> > --
> > -
> > 
> > 
> > pgman wrote:
> > > 
> > > I have backed out this patch.  It is unclear it is a bug fix.
> > > 
> > > It will be saved for 8.1.
> > > 
> > > 
> > --
> > > -
> > > 
> > > pgman wrote:
> > > > 
> > > > Patch applied.  Thanks.
> > > > 
> > > > 
> > 
> > > > ---
> > > > 
> > > > 
> > > > John Hansen wrote:
> > > > > 3 times lucky?
> > > > > 
> > > > > Last one broke utf8 G
> > > > > 
> > > > > This one works, Too tired, sorry for the inconvenience..
> > > > > 
> > > > > ... John
> > > > 
> > > > Content-Description: cvs.diff
> > > > 
> > > > [ Attachment, skipping... ]
> > > > 
> > > > > 
> > > > > ---(end of 
> > > > > broadcast)---
> > > > > TIP 9: the planner will ignore your desire to choose an 
> > index scan if your
> > > > >   joining column's datatypes do not match
> > > > 
> > > > -- 
> > > >   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
> > > 
> > > -- 
> > >   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
> > 
> > > ===
> > > RCS file: /projects/cvsroot/pgsql/src/backend/utils/mb/wchar.c,v
> > > retrieving revision 1.38
> > > diff -c -r1.38 wchar.c
> > > *** src/backend/utils/mb/wchar.c  17 Sep 2004 21:59:57 
> > -   1.38
> > > --- src/backend/utils/mb/wchar.c  21 Nov 2004 09:58:36 -
> > > ***
> > > *** 343,348 
> > > --- 343,373 
> > >   return (pg_euc_dsplen(s));
> > >   }
> > >   
> > > + bool isLegalUTF8(const UTF8 *source, int len) {
> > > + UTF8 a;
> > > + const UTF8 *srcptr = source+len;
> > > + if(!source || (pg_utf_mblen(source) != len)) return false;
> > > + switch (len) {
> > > + default: return false;
> > > + /* Everything else falls through when "true"... */
> > > + case 6: if ((a = (*--srcptr)) < 0x80 || a > 
> > 0xBF) return false;
> > > + case 5: if ((a = (*--srcptr)) < 0x80 || a > 
> > 0xBF) return false;
> > > + case 4: if ((a = (*--srcptr)) < 0x80 || a > 
> > 0xBF) return false;
> > > + case 3: if ((a = (*--srcptr)) < 0x80 || a > 
> > 0xBF) return false;
> > > + case 2: if ((a = (*--srcptr)) > 0xBF) return false;
> > > + switch (*source) {
> > > + /* no fall-through in this inner switch */
> > > + case 0xE0: if (a < 0xA0) return false; break;
> > > + case 0xF0: if (a < 0x90) return false; break;
> > > + case 0xF4: if (a > 0x8F) return false; break;
> > > + default:  if (a < 0x80) return false;
> > > + }
> > > + case 1: if (*source >= 0x80 && *source < 
> > 0xC2) return false;
> > > + if (*source > 0xFD) return false;
> > > + }
> > > + return true;
> > > + }
> > > + 
> > >   /*
> > >* convert UTF-8 string to pg_wchar (UCS-2)
> > >* caller should allocate enough space for "to"
> > > ***
> > > *** 398,404 
> > >* returns the byte length of a UTF-8 word pointed to by s
> > >*/
> > >   int
> > > ! pg_utf_mblen(const unsigned char *s)
> > >   {
> > >   int len = 1;
> > >   
> > >

Re: [PATCHES] [HACKERS] Inefficiency in recent pgtz patch

2005-06-14 Thread Bruce Momjian

Patch applied.  Thanks.

---

Magnus Hagander wrote:
> >> Do you agree that using a hashtable for it in general is a good idea
> >> assuming this sideeffect is removed, though?
> >
> >I have no problem with the hashtable, only with preloading it with
> >everything.  What I'd like to see is that the table inherited at fork()
> >contains just the data for the default timezone.  (At least in the
> >normal case where that setting hasn't been changed since postmaster
> >start.)
> 
> Here's a patch doing this. Changes score_timezone not to use pg_tzset(),
> and thus not loading all the zones in the cache. The actual timezone
> being picked will be set using set_global_timezone() which in turn calls
> pg_tzset() and loads it in the cache.
> 
> 
> //Magnus

Content-Description: tzcache.patch

[ Attachment, skipping... ]

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

-- 
  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 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [PATCHES] psql: \d+ show tablespace of indices

2005-06-14 Thread Bruce Momjian

Patch applied.  Thanks.

---
Qingqing Zhou wrote:
> 
> Now \d show tablespace of indices per discussion.
> 
> test=# \d e
>Table "public.e"
>  Column |  Type   | Modifiers
> +-+---
>  i  | integer | not null
>  j  | integer | not null
>  k  | integer |
> Indexes:
> "e_pkey" PRIMARY KEY, btree (i, j), tablespace "haha"
> "ei" btree (i)
> "ej" btree (j), tablespace "haha"
> "ek" btree (k)
> Tablespace: "haha"
> 
> 

Content-Description: 

[ Attachment, skipping... ]

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

-- 
  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 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] patch between symmetric (add doc)

2005-06-14 Thread Bruce Momjian
Pavel Stehule wrote:
> Hello
> 
>   I add doc and removed words symmetric and asymmetric from 
> keywords. Corrected boolean expression too. This patch don't solve some 
> problems: multiple evaluation of arguments, but its trivial and work with 
> bitmap indexes.

Docs adjusted and patch applied.  Thanks.

-- 
  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.255
diff -c -c -r1.255 func.sgml
*** doc/src/sgml/func.sgml  14 Jun 2005 21:04:38 -  1.255
--- doc/src/sgml/func.sgml  14 Jun 2005 23:46:19 -
***
*** 282,287 
--- 282,293 
  There is no difference between the two respective forms apart from
  the CPU cycles required to rewrite the first one
  into the second one internally.
+ 
+  BETWEEN SYMETRIC
+ 
+ BETWEEN SYMMETRIC is the same as BETWEEN
+ except there is no requirement that the argument to the left of 
AND be less than
+ or equal to the argument on the right;  the proper range is automatically 
determined.
 
  
 
Index: src/backend/parser/gram.y
===
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.492
diff -c -c -r2.492 gram.y
*** src/backend/parser/gram.y   8 Jun 2005 21:15:28 -   2.492
--- src/backend/parser/gram.y   14 Jun 2005 23:46:23 -
***
*** 338,344 
  /* ordinary key words in alphabetical order */
  %token  ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
!   ASSERTION ASSIGNMENT AT AUTHORIZATION
  
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
BOOLEAN_P BOTH BY
--- 338,344 
  /* ordinary key words in alphabetical order */
  %token  ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
!   ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION
  
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
BOOLEAN_P BOTH BY
***
*** 399,405 
SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
!   STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYSID
  
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
--- 399,406 
SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
!   STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYMMETRIC
!   SYSID
  
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
***
*** 6333,6350 
{
$$ = (Node *) 
makeSimpleA_Expr(AEXPR_OF, "!=", $1, (Node *) $6);
}
!   | a_expr BETWEEN b_expr AND b_expr  
%prec BETWEEN
{
$$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
!   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3),
!   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<=", $1, $5));
}
!   | a_expr NOT BETWEEN b_expr AND b_expr  %prec 
BETWEEN
{
$$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
!   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<", $1, $4),
!   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">", $1, $6));
}
| a_expr IN_P in_expr
{
/* in_expr returns a SubLink or a list 
of a_exprs */
--- 6334,6374 
{
$$ = (Node *) 
makeSimpleA_Expr(AEXPR_OF, "!=", $1, (Node *) $6);
}
!   | a_expr BETWEEN opt_asymmetric b_expr AND b_expr   
%prec BETWEEN
{
$$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
!   (Node *) 
ma

Re: [PATCHES] indxpath.c refactoring

2005-06-14 Thread Simon Riggs
On Fri, 2005-06-10 at 18:33 -0400, Tom Lane wrote:
> Simon Riggs <[EMAIL PROTECTED]> writes:
> > This simple refactoring patch moves all of the code associated with
> > Partial Index planning into a single file.
> 
> Applied with some revisions -
> 
> * I put the new predtest.c file into optimizer/util, which seemed a more
>   plausible location than /path, and gave it its own header file.
> 
> * I thought check_partial_indexes() should stay in indxpath.c; it is an
>   application of the theorem-proving module to indexes, not part of the
>   prover proper.
> 
> * I took the opportunity to rename pred_test() to predicate_implied_by(),
>   which seems more clear about what it's doing and in which direction.
> 

Many thanks.

> As for the future...
> 
> > - redesigning the low level routines to allow them to perform their
> > stuff for both Partial Index and Constraint-based elimination (aka
> > Partitioning...)
> 
> The other main entry point should probably be called something like
> predicate_refuted_by?

Will do.

Best Regards, Simon Riggs



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


Re: [PATCHES] Tiny patch on print.c of psql

2005-06-14 Thread Bruce Momjian

I have applied your patch, and added the optimization that only leading
spaces are converted to ' ', as you suggested.

---

Jean-Paul Argudo wrote:
> Hi all,
> 
> This is my 1st patch ever in C :-)... I was just borried by a bad psql
> \H html output of an EXPLAIN
> 
> because it didnt respected spaces sent from backend like:
> 
> -> Sort
> -> Sort
> 
> I just remarked in this print.c the case of a white space wasnt handled 
> in the function escaping special caracters to HTML codes, so I added it 
> replacing a space by special html " " (& n b s p).
> 
> So we'll have now:
> 
> -> Sort
>   -> Sort
> 
> ... in the html generated
> 
> (see example at http://www.pack-solutions.net/~jpargudo/explain.html)
> 
> Then, every single space in the html source is replaced by this. The
> source looks ugly, yes, I will look to *only replacing starting spaces* 
> of each row of the EXPLAIN, thats will be my 1st patch ever, version 2 :)
> 
> So I post this patch only FYI..  I had much fun playing with C a bit :-)
> (yes, I dont code C, just a bit of Perl and Python).
> 
> Cheers! Thanks again for such a powerfull release.
> 
> -- 
> Jean-Paul Argudo
> www.PostgreSQLFr.org


> 
> ---(end of broadcast)---
> TIP 9: the planner will ignore your desire to choose an index scan if your
>   joining column's datatypes do not match

-- 
  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/print.c
===
RCS file: /cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.59
diff -c -c -r1.59 print.c
*** src/bin/psql/print.c14 Jun 2005 02:57:41 -  1.59
--- src/bin/psql/print.c14 Jun 2005 22:14:20 -
***
*** 595,602 
  html_escaped_print(const char *in, FILE *fout)
  {
const char *p;
! 
for (p = in; *p; p++)
switch (*p)
{
case '&':
--- 595,604 
  html_escaped_print(const char *in, FILE *fout)
  {
const char *p;
!   boolleading_space = true;
!   
for (p = in; *p; p++)
+   {
switch (*p)
{
case '&':
***
*** 617,625 
--- 619,637 
case '\'':
fputs("'", fout);
break;
+   case ' ':
+   /* protect leading space, for EXPLAIN output */
+   if (leading_space)
+   fputs(" ", fout);
+   else
+   fputs(" ", fout);
+   break;
default:
fputc(*p, fout);
}
+   if (*p != ' ')
+   leading_space = false;
+   }
  }
  
  

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [PATCHES] uptime function to postmaster

2005-06-14 Thread Bruce Momjian
Euler Taveira de Oliveira wrote:
> Hi Bruce,
> 
> > I think we should return intervals only when we can't return
> > meaningful
> > timestamp values. I don't have any logic to back up that opinion,
> > though.
> > 
> Agreed.
> 
> > 
> > We need to preceed our function names with pg_ for cases like this
> > where
> > we are supplying pg-specific behavior.
> > 
> Agreed.
> 
> An updated version of the patch is attached. It is just implement
> 'pg_start_time' function that works in multi-user and stand-alone. Docs
> is attached too.

I have applied the attached patch, calling the function
pg_postmaster_start_time().  I realize a stand-alone backend doesn't
have a postmaster, but this is probably as clear as we are going to get.

Do we want this to be executed only by super-users?  I know there was
some discussion about that but I didn't see a conclusion.  The only
argument I heard was something about random seeds, but that seemed like
a weak argument.

-- 
  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.254
diff -c -c -r1.254 func.sgml
*** doc/src/sgml/func.sgml  13 Jun 2005 02:40:04 -  1.254
--- doc/src/sgml/func.sgml  14 Jun 2005 20:59:17 -
***
*** 8120,8125 
--- 8120,8131 

  

+pg_postmaster_start_time()
+timestamp with time zone
+postmaster start time
+   
+ 
+   
 user
 name
 equivalent to current_user
***
*** 8217,8222 
--- 8223,8237 
 
  
 
+ pg_postmaster_start_time
+
+ 
+
+  pg_postmaster_start_time() returns the timestamp 
with time zone
+  when the postmaster started.
+
+ 
+
  version
 
  
Index: src/backend/postmaster/postmaster.c
===
RCS file: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.452
diff -c -c -r1.452 postmaster.c
*** src/backend/postmaster/postmaster.c 9 Jun 2005 22:01:12 -   1.452
--- src/backend/postmaster/postmaster.c 14 Jun 2005 20:59:21 -
***
*** 222,227 
--- 222,230 
  bool  ClientAuthInProgress = false;   /* T during new-client

 * authentication */
  
+ /* Backend startup time */
+ TimestampTz   StartTime;
+ 
  /*
   * State for assigning random salts and cancel keys.
   * Also, the global MyCancelKey passes the cancel key assigned to a given
***
*** 330,335 
--- 333,339 
InheritableSocket pgStatPipe0;
InheritableSocket pgStatPipe1;
pid_t PostmasterPid;
+   TimestampTz StartTime;
  #ifdef WIN32
HANDLE PostmasterHandle;
HANDLE initial_signal_pipe;
***
*** 372,377 
--- 376,384 
char   *userDoption = NULL;
int i;
  
+   AbsoluteTimeStartTimeSec;   /* integer part */
+   int StartTimeUSec;  /* microsecond part */
+ 
/* This will call exit() if strdup() fails. */
progname = get_progname(argv[0]);   
  
***
*** 914,919 
--- 921,932 
 */
StartupPID = StartupDataBase();
  
+   /*
+* Get start up time
+*/
+   StartTimeSec = GetCurrentAbsoluteTimeUsec(&StartTimeUSec);
+   StartTime = AbsoluteTimeUsecToTimestampTz(StartTimeSec, StartTimeUSec);
+ 
status = ServerLoop();
  
/*
***
*** 3603,3608 
--- 3616,3622 
write_inheritable_socket(¶m->pgStatPipe1, pgStatPipe[1], childPid);
  
param->PostmasterPid = PostmasterPid;
+   param->StartTime = StartTime;
  
  #ifdef WIN32
param->PostmasterHandle = PostmasterHandle;
***
*** 3805,3810 
--- 3819,3825 
read_inheritable_socket(&pgStatPipe[1], ¶m->pgStatPipe1);
  
PostmasterPid = param->PostmasterPid;
+   StartTime = param->StartTime;
  
  #ifdef WIN32
PostmasterHandle = param->PostmasterHandle;
Index: src/backend/tcop/postgres.c
===
RCS file: /cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.447
diff -c -c -r1.447 postgres.c
*** src/backend/tcop/postgres.c 3 Jun 2005 23:05:29 -   1.447
--- src/backend/tcop/postgres.c 14 Jun 2005 20:59:22 -
***
*** 149,154 
--- 149,157 
  #endif   /* TCOP_DONTUSENEWLINE */
  
  
+ /* Backend startup time */
+ TimestampTz   StartTime;
+ 
  /* -

Re: [PATCHES] SHOW ALL with descriptions

2005-06-14 Thread Bruce Momjian
Matthias Schmidt wrote:
> Hi *,
> 
> here's a tiny patch showing the description of the backend parameters 
> alongside the 'SHOW ALL' Command.
> I'm not quite shure wether this should be the default output or not. 
> Probably this needs to be configurable itself.
> 
> What do you think?

Good question.  psql \dT shows descriptions, but \df does not, only
\df+, so that doesn't give us a pattern.

We could add a VERBOSE option to SHOW ALL to show descriptions, but that
seems like overkill.

I have applied your patch that show descriptions for SHOW ALL, but not
for SHOW varname.  That seems like the cleanest solution.  I also
updated the documentation to mention SHOW ALL includes descriptions.

Any modification suggestions from the group?

-- 
  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/show.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v
retrieving revision 1.38
diff -c -c -r1.38 show.sgml
*** doc/src/sgml/ref/show.sgml  8 Apr 2005 00:59:58 -   1.38
--- doc/src/sgml/ref/show.sgml  14 Jun 2005 20:39:20 -
***
*** 118,124 
  ALL
  
   
!   Show the values of all configuration parameters.
   
  
 
--- 118,124 
  ALL
  
   
!   Show the values of all configuration parameters, with descriptions.
   
  
 
***
*** 164,180 
 Show all settings:
  
  SHOW ALL;
!   name  | setting
! 
+--
!  add_missing_from   | off
!  archive_command| unset
!  australian_timezones   | off
  .
  .
  .
!  work_mem   | 1024
!  zero_damaged_pages | off
! (140 rows)
  

   
--- 164,180 
 Show all settings:
  
  SHOW ALL;
!   name  |setting |
 description
  
! 
++--
!  add_missing_from   | off| 
Automatically adds missing table references to FROM clauses.
!  archive_command| unset  | WAL 
archiving command.
!  australian_timezones   | off| Interprets 
ACST, CST, EST, and SAT as Australian time zones.
  .
  .
  .
!  work_mem   | 1024   | Sets the 
maximum memory to be used for query workspaces.
!  zero_damaged_pages | off| Continues 
processing past damaged page headers.
! (146 rows)
  

   
Index: src/backend/utils/misc/guc.c
===
RCS file: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.265
diff -c -c -r1.265 guc.c
*** src/backend/utils/misc/guc.c14 Jun 2005 17:43:13 -  1.265
--- src/backend/utils/misc/guc.c14 Jun 2005 20:39:24 -
***
*** 4337,4348 
  
if (pg_strcasecmp(name, "all") == 0)
{
!   /* need a tuple descriptor representing two TEXT columns */
!   tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
   TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
   TEXTOID, -1, 0);
}
else
{
--- 4337,4351 
  
if (pg_strcasecmp(name, "all") == 0)
{
!   /* need a tuple descriptor representing three TEXT columns */
!   tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
   TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
   TEXTOID, -1, 0);
+   TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
+  TEXTOID, -1, 0);
+ 
}
else
{
***
*** 4415,4428 
int i;
TupOutputState *tstate;
TupleDesc   tupdesc;
!   char   *values[2];
  
!   /* need a tuple descriptor representing two TEXT columns */
!   tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescI

Re: [PATCHES] pg_config MSVC makefile

2005-06-14 Thread Bruce Momjian

Patch applied.  Thanks.

I also updated the top-level win32.mak for this.

---


Andrew Dunstan wrote:
> 
> Attached is a makefile I hacked up to build pg_config under MSVC - the 
> reason is that it's required (more or less) in order to build the latest 
> DBD::Pg code and I was testing that out under MSVC. Should be saved as 
> src/bin/pg_config/win32.mak if we're to be consistent. I haven't yet 
> done a patch to the upper level makefile to call it.
> 
> cheers
> 
> andrew

> # Makefile for Microsoft Visual C++ 5.0 (or compat)
> 
> !IF "$(OS)" == "Windows_NT"
> NULL=
> !ELSE 
> NULL=nul
> !ENDIF 
> 
> CPP=cl.exe
> 
> !IFDEF DEBUG
> OPT=/Od /Zi /MDd
> LOPT=/DEBUG
> DEBUGDEF=/D _DEBUG
> OUTDIR=.\Debug
> INTDIR=.\Debug
> !ELSE
> OPT=/O2 /MD
> LOPT=
> DEBUGDEF=/D NDEBUG
> OUTDIR=.\Release
> INTDIR=.\Release
> !ENDIF
> 
> ALL : "..\..\port\pg_config_paths.h" "$(OUTDIR)\pg_config.exe"
> 
> CLEAN :
>   [EMAIL PROTECTED] "$(INTDIR)\pg_config.obj"
>   [EMAIL PROTECTED] "$(OUTDIR)\pg_config.exe"
>   [EMAIL PROTECTED] "$(INTDIR)\..\..\port\pg_config_paths.h"
> 
> "..\..\port\pg_config_paths.h": win32.mak
>   echo #define PGBINDIR "" >$@
>   echo #define PGSHAREDIR "" >>$@
>   echo #define SYSCONFDIR "" >>$@
>   echo #define INCLUDEDIR "" >>$@
>   echo #define PKGINCLUDEDIR "" >>$@
>   echo #define INCLUDEDIRSERVER "" >>$@
>   echo #define LIBDIR "" >>$@
>   echo #define PKGLIBDIR "" >>$@
>   echo #define LOCALEDIR "" >>$@
> 
> "$(OUTDIR)" :
> if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
> 
> CPP_PROJ=/nologo $(OPT) /W3 /GX /D "WIN32" $(DEBUGDEF) /D "_CONSOLE" /D\
>  "_MBCS" /Fp"$(INTDIR)\pg_config.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" 
> /FD /c \
>  /I ..\..\include /I ..\..\interfaces\libpq /I ..\..\include\port\win32 \
>  /D "HAVE_STRDUP" /D "FRONTEND" /D VAL_CONFIGURE="\"\""
> 
> CPP_OBJS=$(INTDIR)/
> CPP_SBRS=.
> 
> LINK32=link.exe
> LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
>  advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
>  odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
>  /pdb:"$(OUTDIR)\pg_config.pdb" /machine:I386 $(LOPT) 
> /out:"$(OUTDIR)\pg_config.exe" 
> LINK32_OBJS= \
>   "$(INTDIR)\pg_config.obj" \
>   "$(INTDIR)\pgstrcasecmp.obj" \
>   "$(OUTDIR)\path.obj" \
>   "$(INTDIR)\exec.obj" \
> !IFDEF DEBUG
>   "..\..\interfaces\libpq\Debug\libpqddll.lib"
> !ELSE
>   "..\..\interfaces\libpq\Release\libpqdll.lib"
> !ENDIF
> 
> "$(OUTDIR)\pg_config.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
> $(LINK32) @<<
>   $(LINK32_FLAGS) $(LINK32_OBJS)
> <<
> 
> "$(OUTDIR)\path.obj" : "$(OUTDIR)" ..\..\port\path.c
> $(CPP) @<<
> $(CPP_PROJ) ..\..\port\path.c
> <<
> 
> "$(INTDIR)\pgstrcasecmp.obj" : ..\..\port\pgstrcasecmp.c
> $(CPP) @<<
> $(CPP_PROJ) ..\..\port\pgstrcasecmp.c
> <<
> 
> "$(INTDIR)\exec.obj" : ..\..\port\exec.c
> $(CPP) @<<
> $(CPP_PROJ) ..\..\port\exec.c
> <<
> 
> .c{$(CPP_OBJS)}.obj::
>$(CPP) @<<
>$(CPP_PROJ) $< 
> <<
> 
> .cpp{$(CPP_OBJS)}.obj::
>$(CPP) @<<
>$(CPP_PROJ) $< 
> <<
> 

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

-- 
  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 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [PATCHES] patch to add krb_server_hostname to postgresql.conf

2005-06-14 Thread Bruce Momjian

Second patch applied:

Add GUC krb_server_hostname so the server hostname can be specified as
part of service principal.  If not set, any service principal matching
an entry in the keytab can be used.

I updated your documentation to reflect this.

Thanks.

---

Todd Kover wrote:
>  > Todd Kover <[EMAIL PROTECTED]> writes:
>  >
>  > > The attached patch adds a directive to the config file,
>  > > krb_server_hostname that allows the hostname that service tickets
>  > > are obtained against to be different from the hostname of the db
>  > > server.
>  >
>  > Why is this necessary?
> 
> It's largely useful in combination with restricting the interfaces
> listened to via the listen_addresses directive in the config file.  As
> the code works now you can only connect via kerberos with a service
> principal derived from the hostname of the box rather than any dns name
> associated with any of the box's interfaces.
> 
> For example, if the server is named server0.example.com, but the db is
> bound to db.example.com via the listen_addresses directive, the pgsql
> server won't authenticate properly.
> 
> Similarly, if server0.example.com is one interface and
> server1.example.com is another, and the hostname is server.example.com
> but doesn't correspond to any interfaces, connecting to neither will
> work.
> 
>  > If it is necessary, wouldn't something similar be needed at the
>  > client end as well?
> 
> No.  The decision of which principal to obtain a service ticket for is
> based on what it connects to.
> 
> In the first above example, if running:
> 
>   psql -h server0.example.com
> 
> the client would obtain a service ticket for
> postgres/server0.example.com.  If running:
> 
>   psql -h db.example.com
> 
> it would obtain a service ticket for postgres/db.example.com, and
> without the directive I'm adding, it would fail to establish a
> connection because the server wouldn't be expecting that.  Of course,
> adding the directive would make the first case fail and the second
> pass.  This works fine for our environment since we're binding to
> db.example.com.
> 
> (as an aside, it's actually a bit more complicated then this since the
> way the kerberos libraries are used, db.example.com is canonicalized, so
> if it were a CNAME for server0.example.com it would do the right thing,
> but we're using an A record).
> 
>  > I'd have thought that host information would be established by some
>  > sort of system-wide configuration file, not by per-program options.
> 
> Different applications can use different service principals.  The use
> of the hostname in the principal name at all is an application-specific
> decision.  The krb5 api encourages it to be a DNS hostname pretty
> strongly in the way it works, but it's not cast in stone.
> 
> However, other kerberos clients will accept using any kerberos principal
> in the keytab but postgresql as shipped requires it to match the
> hostname.  If you want that behavior instead, then change pg_krb5_server
> to NULL when calling krb5_recvauth in src/backend/libpq/auth.c and it
> won't require that the hostnames match. (but it's still necessary for
> something to match).
> 
> The second patch (kovert-krb5-patch-newbehavior.txt) makes the default
> behavior to accept any principal in the keytab.  This means that people
> using kerberos will continue to work, but they'll be slightly more broad
> in what they accept as a valid service principal (I suspect there's very
> few people in the world who care about this since it still needs to be
> something in the keytab).
> 
> I left the implementation of krb_server_hostname so that someone can
> define this if they want. (and if they want to make it behave like
> versions of pgsql up until now, they'd need to set it to the hostname).
> 
> The second patch's default case makes pgsql match the behavior of
> eklogind (kerberized rlogind that ships with MIT kerberos) and the
> gssapi/krb5-aware version of sshd and probably numerous other things.
> 
>  > Also, the available documentation says that PG_KRB_SRVNAM is a
>  > service name, not a host name, so I feel like there's something wrong
>  > with your description of what you're doing.
> 
> indeed, there was something wrong with what I was doing.  PG_KRB_SRVNAM
> defaults to 'postgres' rather than the hostname.  This was fallout from
> when I was first developing the patch.
> 
> The absence of the krb_server_hostname config flag should have left the
> default behavior in place, it wasn't.  I just tested this patch against
> both cases on a dev box and it works as expected.
> 
> both patches are against 8.0.0rc3.  The first implements what I
> originally was doing without changing the default, the second changes
> the default to be more accepting and also implements the directive in
> case someone wants to go back to the old behavior.
> 
> -Todd
> 

> Index: doc/src/sgml/runtime.

[PATCHES] replace_text() improvement

2005-06-14 Thread Atsushi Ogawa

(BI made the patch that improved the performance of replace_text().
(BThe content of the patch is as follows:
(B
(B(1)Create shortcut when subtext was not found.
(B
(B(2)Stop using LEFT and RIGHT macro.
(BIn LEFT and RIGHT macro, TEXTPOS is executed by the same content as
(Bexecution immediately before. The execution frequency of TEXTPOS can be
(Breduced by using text_substring instead of LEFT and RIGHT macro.
(B
(B(3)Add appendStringInfoText, and use it instead of appendStringInfoString.
(BThere is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
(Bexecuted by text type. This can be reduced by appendStringInfoText.
(B
(B(4)Reduce execution of TEXTDUP. 
(B
(BThe effect of the patch that I measured is as follows:
(B
(B- The Data for test was created by 'pgbench -i'.
(B
(B- Test SQL:
(B select replace(aid, '9', 'A') from accounts;
(B
(B- Test results: Linux(CPU: Pentium III, Compiler option: -O2)
(B original: 1.515s
(B patched:  1.250s
(B
(Bregards,
(B
(B---
(BAtsushi Ogawa

replace_text.patch
Description: Binary data

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