[PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Dave Page
When starting as a service at boot time on Windows, pg_autovacuum may
fail to start because the PostgreSQL service is still starting up. This
patch causes the service to attempt a second connection 30 seconds after
the initial connection failure before giving up entirely.

Regards, Dave


startup_delay.diff
Description: startup_delay.diff

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


Re: [PATCHES] LRU

2005-01-24 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 In other words, you might be able to somewhat reduce the size of the
 patch by, say, not renaming some exported functions in freelist.c, but I
 don't see that that will have a significant effect upon the complexity
 of the patch or the risk that it might cause regressions.

Well, the thing that's bothering me is that you are undoing a number of
changes that we'll probably just have to redo later; with consequently
*two* chances to introduce bugs.  Case in point is moving the
responsibility for this:

+   /*
+* Clear the buffer's tag.  This doesn't matter for the hash table,
+* since the buffer is already removed from it, but it ensures that
+* sequential searches through the buffer table won't think the buffer
+* is still valid for its old page.
+*/
+   CLEAR_BUFFERTAG(buf-tag);

out of freelist.c and putting it back in bufmgr.c.  Jan actually
introduced a bug in his original ARC patch by deleting this code from
BufTableDelete and forgetting to put equivalent defenses into freelist.c.
I've got little confidence that this patch doesn't create some similar
problem, and none that we won't make the same mistake over again when
we re-revert the division of labor.

In short I'd rather try to minimize the amount of API churn that bufmgr.c
sees in this patch, because we'll probably just be changing it back later.

If the problem is that the current freelist.c API exposes too much about
the ARC implementation, the answer to that is not to go back to exposing
the LRU-list implementation; it's to generalize the API.

regards, tom lane

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


[PATCHES] Fix for SHGetSpecialFolderPath

2005-01-24 Thread Magnus Hagander
Attached patch fixes the SHGetSpecialFolderPath issues on NT4. It does
this by using SHGetFolderPath instead of SHGetSpecialFolderPath, and
linking to shfolder.dll instead of shell32.dll. shfolder.dll exists as a
redistributable from Microsoft in case it is needed on a system, and
it's supported on all current windows platforms.

I have tested the patch on 2003, XP, 2000 and NT4, and it passes on all
of them (I verified that psqlrc.conf and pgpass.conf works - I'm
assuming the rest of the fiels work as well then since they use the same
function to get the file).

MingW and MSVC builds updated, haven't touched the Borland stuff.

Please consider for both 8.0.1 and HEAD. (and if some more win32 ppl can
test it, even better :P)


//Magnus



shfolder.patch
Description: shfolder.patch

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


Re: [PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Tom Lane
Dave Page dpage@vale-housing.co.uk writes:
 When starting as a service at boot time on Windows, pg_autovacuum may
 fail to start because the PostgreSQL service is still starting up. This
 patch causes the service to attempt a second connection 30 seconds after
 the initial connection failure before giving up entirely.

Hm.  In event that the system crashed beforehand, it could require much
more than 30 seconds to finish replaying the old WAL log.  So the above
doesn't seem super robust to me.  Would it be reasonable to try every 30
seconds for five minutes, or some such?  (Five minutes at least has a
defensible rationale, ie it's the default checkpoint interval and we
expect we can replay the log at least as fast as it was created
initially.)

regards, tom lane

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


Re: [PATCHES] LRU

2005-01-24 Thread Neil Conway
On Mon, 2005-01-24 at 17:39 -0500, Tom Lane wrote:
 I'm more than slightly uncomfortable with the size of this patch.
[...]
 I think it would be better and safer to try to localize the changes
 into freelist.c.

IMHO that is basically what the patch does; the changes to other files
are either cosmetic or are required to change the replacement strategy.
More specifically, diffstat shows:

 doc/src/sgml/runtime.sgml |   48 -
 src/backend/catalog/index.c   |2 
 src/backend/commands/dbcommands.c |4 
 src/backend/commands/vacuum.c |   27 
 src/backend/postmaster/bgwriter.c |3 
 src/backend/storage/buffer/buf_init.c |   55 !
 src/backend/storage/buffer/buf_table.c|   67 !
 src/backend/storage/buffer/bufmgr.c   |  177 -!!
 src/backend/storage/buffer/freelist.c |
1031 !
 src/backend/utils/misc/guc.c  |   19 
 src/backend/utils/misc/postgresql.conf.sample |1 
 src/include/postmaster/bgwriter.h |1 
 src/include/storage/buf_internals.h   |   85 !!
 src/include/storage/bufmgr.h  |2 
 14 files changed, 56 insertions(+), 139 deletions(-), 1327
modifications(!)

A summary of the changes made to each file:

runtime.sgml: doc updates
index.c: trivial API change (BufferSync)
dbcommands.c: trivial API change (BufferSync)
vacuum.c: trivial API change (StrategyVacuumHint)
bgwriter.c: trivial API change (BufferSync), remove bgwriter_percent
buf_init.c: changes required for LRU
buf_table.c: changes required for LRU (or more properly, reverting some
modifications to the buf_table stuff that was part of the ARC patch: the
patch should be very close to the buf_table in 7.4)
bufmgr.c: move PinBuffer() and UnpinBuffer() to freelist.c, replace
StrategyXXX calls with similar calls to BufTableXXX and so on. Some
BufferSync API changes. Most of these changes are pretty
straightforward.
freelist.c: obvious :)
guc.c: remove bgwriter_percent and debug_shared_buffers
postgresql.conf.sample: remove bgwriter_percent
bgwriter.h: remove bgwriter_percent
buf_internals.h: changes necessary for LRU
bufmgr.h: BufferSync API change

In other words, you might be able to somewhat reduce the size of the
patch by, say, not renaming some exported functions in freelist.c, but I
don't see that that will have a significant effect upon the complexity
of the patch or the risk that it might cause regressions. If you have
specific suggestions about how to reduce the scope of the patch I'm all
ears, but I don't think the size of the patch is necessarily the most
reliable metric for the probability it will result in a regression.

-Neil



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


Re: [PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes:
 On Mon, Jan 24, 2005 at 06:57:54PM -0500, Tom Lane wrote:
 (Five minutes at least has a defensible rationale, ie it's the default
 checkpoint interval and we expect we can replay the log at least as
 fast as it was created initially.)

 Hmm, I remember Mark Wong from OSDL saying that it took to replay the
 logs after a crash more than the six hours it had taken to generate
 them.

Six hours?  Did he have checkpoints disabled somehow?

regards, tom lane

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


Re: [PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Alvaro Herrera
On Mon, Jan 24, 2005 at 06:57:54PM -0500, Tom Lane wrote:

 (Five minutes at least has a defensible rationale, ie it's the default
 checkpoint interval and we expect we can replay the log at least as
 fast as it was created initially.)

Hmm, I remember Mark Wong from OSDL saying that it took to replay the
logs after a crash more than the six hours it had taken to generate
them.  Simon commented that it was unexpected, but there was no further
comment on the issue.

(On his test the server is generating the logs as fast as it can, so it
may not be important, but anyway ... )

-- 
Alvaro Herrera ([EMAIL PROTECTED])
Ciencias políticas es la ciencia de entender por qué
 los políticos actúan como lo hacen  (netfunny.com)

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


[PATCHES] add regression test for #1433

2005-01-24 Thread Neil Conway
This patch adds a regression test for the bug with domains and ALTER
TABLE that Tom fixed a few hours ago.

Barring any objections I'll apply this to HEAD by the end of the day.

-Neil

Index: src/test/regress/expected/domain.out
===
RCS file: /var/lib/cvs/pgsql/src/test/regress/expected/domain.out,v
retrieving revision 1.32
diff -c -r1.32 domain.out
*** src/test/regress/expected/domain.out	5 Aug 2004 03:30:03 -	1.32
--- src/test/regress/expected/domain.out	25 Jan 2005 00:55:11 -
***
*** 300,302 
--- 300,316 
  drop domain ddef3 restrict;
  drop domain ddef4 restrict;
  drop domain ddef5 restrict;
+ -- Make sure that constraints of newly-added domain columns are
+ -- enforced correctly, even if there's no default value for the new
+ -- column. Per bug #1433
+ create domain str_domain as text not null;
+ create table domain_test (a int, b int);
+ insert into domain_test values (1, 2);
+ insert into domain_test values (1, 2);
+ -- should fail
+ alter table domain_test add column c str_domain;
+ ERROR:  domain str_domain does not allow null values
+ create domain str_domain2 as text check (value  'foo') default 'foo';
+ -- should fail
+ alter table domain_test add column d str_domain2;
+ ERROR:  value for domain str_domain2 violates check constraint str_domain2_check
Index: src/test/regress/sql/domain.sql
===
RCS file: /var/lib/cvs/pgsql/src/test/regress/sql/domain.sql,v
retrieving revision 1.17
diff -c -r1.17 domain.sql
*** src/test/regress/sql/domain.sql	5 Aug 2004 03:30:44 -	1.17
--- src/test/regress/sql/domain.sql	25 Jan 2005 00:51:43 -
***
*** 244,246 
--- 244,264 
  drop domain ddef3 restrict;
  drop domain ddef4 restrict;
  drop domain ddef5 restrict;
+ 
+ -- Make sure that constraints of newly-added domain columns are
+ -- enforced correctly, even if there's no default value for the new
+ -- column. Per bug #1433
+ create domain str_domain as text not null;
+ 
+ create table domain_test (a int, b int);
+ 
+ insert into domain_test values (1, 2);
+ insert into domain_test values (1, 2);
+ 
+ -- should fail
+ alter table domain_test add column c str_domain;
+ 
+ create domain str_domain2 as text check (value  'foo') default 'foo';
+ 
+ -- should fail
+ alter table domain_test add column d str_domain2;

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


Re: [PATCHES] add regression test for #1433

2005-01-24 Thread Neil Conway
On Mon, 2005-01-24 at 22:22 -0500, Tom Lane wrote:
 It might be better to make the tables TEMP tables --- there are some
 regression tests that depend on the set of existing tables, IIRC.
 Otherwise ok.

True, although those kind of dependencies usually cause an obvious test
failure (which this patch doesn't cause). I've been thinking that
there's some value in keeping database objects creating by regression
tests around, so that we get better pg_dump coverage (a quick and dirty
pg_dump test is to dump the database created by make installcheck and
restore it). Admittedly this is pretty primitive, but it's better than
nothing.

[ Sorry for applying the patch already, I hadn't received your mail ]

-Neil



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


Re: [PATCHES] add regression test for #1433

2005-01-24 Thread Neil Conway
On Tue, 2005-01-25 at 11:56 +1100, Neil Conway wrote:
 This patch adds a regression test for the bug with domains and ALTER
 TABLE that Tom fixed a few hours ago.

Applied.

-Neil



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

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


Re: [PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Matthew T. O'Connor
Dave Page wrote:
When starting as a service at boot time on Windows, pg_autovacuum may
fail to start because the PostgreSQL service is still starting up. This
patch causes the service to attempt a second connection 30 seconds after
the initial connection failure before giving up entirely.
 

In the windows service world, is there any reason pg_autovacuum should 
ever give up?  The reason I had it give up was so that it didn't 
accidently run against a different postgresql instance.  I don't think 
that will happen in the windows service world.  I think it should keep 
trying to do it's job until it's told to exit.

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


Re: [PATCHES] add regression test for #1433

2005-01-24 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 This patch adds a regression test for the bug with domains and ALTER
 TABLE that Tom fixed a few hours ago.

It might be better to make the tables TEMP tables --- there are some
regression tests that depend on the set of existing tables, IIRC.
Otherwise ok.

regards, tom lane

---(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


[PATCHES] add soundex difference function to contrib/fuzzystrmatch

2005-01-24 Thread Kris Jurka

The attached patch implements the soundex difference function which 
compares two strings' soundex values for similarity.

http://databases.about.com/od/development/l/aasoundex.htm

Kris Jurka? contrib/fuzzystrmatch/.deps
? contrib/fuzzystrmatch/fuzzystrmatch.sql
? contrib/fuzzystrmatch/libfuzzystrmatch.so.0.0
Index: contrib/fuzzystrmatch/README.fuzzystrmatch
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/README.fuzzystrmatch,v
retrieving revision 1.7
diff -c -r1.7 README.fuzzystrmatch
*** contrib/fuzzystrmatch/README.fuzzystrmatch  1 Jan 2005 20:44:11 -   
1.7
--- contrib/fuzzystrmatch/README.fuzzystrmatch  25 Jan 2005 06:07:11 -
***
*** 33,38 
--- 33,42 
   * Folded existing soundex contrib into this one. Renamed text_soundex() (C 
function)
   * to soundex() for consistency.
   *
+  * difference()
+  * 
+  * Return the difference between two strings' soundex values.  Kris Jurka
+  *
   * Permission to use, copy, modify, and distribute this software and its
   * documentation for any purpose, without fee, and without a written agreement
   * is hereby granted, provided that the above copyright notice and this
Index: contrib/fuzzystrmatch/README.soundex
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/README.soundex,v
retrieving revision 1.2
diff -c -r1.2 README.soundex
*** contrib/fuzzystrmatch/README.soundex1 Jul 2004 03:25:48 -   
1.2
--- contrib/fuzzystrmatch/README.soundex25 Jan 2005 06:07:11 -
***
*** 7,21 
--- 7,31 
  beyond English names (or the English pronunciation of names), and
  it is not a linguistic tool.
  
+ When comparing two soundex values to determine similarity, the
+ difference function reports how close the match is on a scale
+ from zero to four, with zero being no match and four being an
+ exact match.
+ 
  The following are some usage examples:
  
  SELECT soundex('hello world!');
  
+ SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');
+ SELECT soundex('Anne'), soundex('Andrew'), difference('Anne', 'Andrew');
+ SELECT soundex('Anne'), soundex('Margaret'), difference('Anne', 'Margaret');
+ 
  CREATE TABLE s (nm text)\g
  
  insert into s values ('john')\g
  insert into s values ('joan')\g
  insert into s values ('wobbly')\g
+ insert into s values ('jack')\g
  
  select * from s
  where soundex(nm) = soundex('john')\g
***
*** 58,62 
  WHERE text_sx_eq(nm,'john')\g
  
  SELECT *
! from s
! where s.nm #= 'john';
--- 68,77 
  WHERE text_sx_eq(nm,'john')\g
  
  SELECT *
! FROM s
! WHERE s.nm #= 'john';
! 
! SELECT *
! FROM s
! WHERE difference(s.nm, 'john')  2;
! 
Index: contrib/fuzzystrmatch/fuzzystrmatch.c
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v
retrieving revision 1.14
diff -c -r1.14 fuzzystrmatch.c
*** contrib/fuzzystrmatch/fuzzystrmatch.c   1 Jan 2005 05:43:06 -   
1.14
--- contrib/fuzzystrmatch/fuzzystrmatch.c   25 Jan 2005 06:07:11 -
***
*** 755,757 
--- 755,777 
++count;
}
  }
+ 
+ PG_FUNCTION_INFO_V1(difference);
+ 
+ Datum
+ difference(PG_FUNCTION_ARGS)
+ {
+   char sndx1[SOUNDEX_LEN+1], sndx2[SOUNDEX_LEN+1];
+   int i, result;
+ 
+   _soundex(_textout(PG_GETARG_TEXT_P(0)), sndx1);
+   _soundex(_textout(PG_GETARG_TEXT_P(1)), sndx2);
+ 
+   result = 0;
+   for (i=0; iSOUNDEX_LEN; i++) {
+   if (sndx1[i] == sndx2[i])
+   result++;
+   }
+ 
+   PG_RETURN_INT32(result);
+ }
Index: contrib/fuzzystrmatch/fuzzystrmatch.h
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/fuzzystrmatch.h,v
retrieving revision 1.10
diff -c -r1.10 fuzzystrmatch.h
*** contrib/fuzzystrmatch/fuzzystrmatch.h   1 Jan 2005 05:43:06 -   
1.10
--- contrib/fuzzystrmatch/fuzzystrmatch.h   25 Jan 2005 06:07:11 -
***
*** 60,65 
--- 60,66 
  extern Datum levenshtein(PG_FUNCTION_ARGS);
  extern Datum metaphone(PG_FUNCTION_ARGS);
  extern Datum soundex(PG_FUNCTION_ARGS);
+ extern Datum difference(PG_FUNCTION_ARGS);
  
  /*
   * Soundex
Index: contrib/fuzzystrmatch/fuzzystrmatch.sql.in
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/fuzzystrmatch.sql.in,v
retrieving revision 1.6
diff -c -r1.6 fuzzystrmatch.sql.in
*** contrib/fuzzystrmatch/fuzzystrmatch.sql.in  1 Jul 2004 03:25:48 -   
1.6
--- contrib/fuzzystrmatch/fuzzystrmatch.sql.in  25 Jan 2005 06:07:11 -
***
*** 19,24 
--- 19,28 
  AS 'MODULE_PATHNAME', 'soundex'
  LANGUAGE 'C';
  
+ CREATE FUNCTION difference(text,text) RETURNS int
+ AS 

Re: [PATCHES] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Michael Paesold
Tom Lane wrote:
Alvaro Herrera [EMAIL PROTECTED] writes:
On Mon, Jan 24, 2005 at 06:57:54PM -0500, Tom Lane wrote:
(Five minutes at least has a defensible rationale, ie it's the default
checkpoint interval and we expect we can replay the log at least as
fast as it was created initially.)

Hmm, I remember Mark Wong from OSDL saying that it took to replay the
logs after a crash more than the six hours it had taken to generate
them.
Six hours?  Did he have checkpoints disabled somehow?
No, I remember they were talking about recovery from backup using PITR.
(i.e. not simple crash recovery, but replaying the logs from the whole 
benchmark session)

Best Regards,
Michael Paesold 

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


Re: [PATCHES] add soundex difference function to

2005-01-24 Thread Neil Conway
On Tue, 2005-01-25 at 01:13 -0500, Kris Jurka wrote:
 The attached patch implements the soundex difference function which 
 compares two strings' soundex values for similarity.

*** 19,24 
--- 19,28 
  AS 'MODULE_PATHNAME', 'soundex'
  LANGUAGE 'C';
  
+ CREATE FUNCTION difference(text,text) RETURNS int
+ AS 'MODULE_PATHNAME', 'difference'
+ LANGUAGE 'C';
+ 

This should be immutable, right?

-Neil



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


Re: [PATCHES] add soundex difference function to contrib/fuzzystrmatch

2005-01-24 Thread Kris Jurka


On Tue, 25 Jan 2005, Neil Conway wrote:

 On Tue, 2005-01-25 at 01:13 -0500, Kris Jurka wrote:
  The attached patch implements the soundex difference function which 
  compares two strings' soundex values for similarity.
 
 *** 19,24 
 --- 19,28 
   AS 'MODULE_PATHNAME', 'soundex'
   LANGUAGE 'C';
   
 + CREATE FUNCTION difference(text,text) RETURNS int
 + AS 'MODULE_PATHNAME', 'difference'
 + LANGUAGE 'C';
 + 
 
 This should be immutable, right?
 

Yes, it should, and even more importantly strict because it crashes when
called with null inputs.  I copied this off the adjacent entry without
thinking about it.  So currently SELECT text_soundex(NULL); crashes the
server.  I've attached two new patches.  One revising my original patch to
make the function creations consistent and the other to just fix the
problem in the existing code (which should be backported as far as people
would like to).

Kris JurkaIndex: contrib/fuzzystrmatch/fuzzystrmatch.sql.in
===
RCS file: /cvsroot/pgsql/contrib/fuzzystrmatch/fuzzystrmatch.sql.in,v
retrieving revision 1.6
diff -c -r1.6 fuzzystrmatch.sql.in
*** contrib/fuzzystrmatch/fuzzystrmatch.sql.in  1 Jul 2004 03:25:48 -   
1.6
--- contrib/fuzzystrmatch/fuzzystrmatch.sql.in  25 Jan 2005 07:21:08 -
***
*** 17,23 
  
  CREATE FUNCTION text_soundex(text) RETURNS text
  AS 'MODULE_PATHNAME', 'soundex'
! LANGUAGE 'C';
  
  CREATE FUNCTION dmetaphone (text) RETURNS text 
  LANGUAGE C IMMUTABLE STRICT
--- 17,23 
  
  CREATE FUNCTION text_soundex(text) RETURNS text
  AS 'MODULE_PATHNAME', 'soundex'
! LANGUAGE 'C' WITH (iscachable, isstrict);
  
  CREATE FUNCTION dmetaphone (text) RETURNS text 
  LANGUAGE C IMMUTABLE STRICT
? contrib/fuzzystrmatch/.deps
? contrib/fuzzystrmatch/fuzzystrmatch.sql
? contrib/fuzzystrmatch/libfuzzystrmatch.so.0.0
Index: contrib/fuzzystrmatch/README.fuzzystrmatch
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/README.fuzzystrmatch,v
retrieving revision 1.7
diff -c -r1.7 README.fuzzystrmatch
*** contrib/fuzzystrmatch/README.fuzzystrmatch  1 Jan 2005 20:44:11 -   
1.7
--- contrib/fuzzystrmatch/README.fuzzystrmatch  25 Jan 2005 07:16:41 -
***
*** 33,38 
--- 33,42 
   * Folded existing soundex contrib into this one. Renamed text_soundex() (C 
function)
   * to soundex() for consistency.
   *
+  * difference()
+  * 
+  * Return the difference between two strings' soundex values.  Kris Jurka
+  *
   * Permission to use, copy, modify, and distribute this software and its
   * documentation for any purpose, without fee, and without a written agreement
   * is hereby granted, provided that the above copyright notice and this
Index: contrib/fuzzystrmatch/README.soundex
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/README.soundex,v
retrieving revision 1.2
diff -c -r1.2 README.soundex
*** contrib/fuzzystrmatch/README.soundex1 Jul 2004 03:25:48 -   
1.2
--- contrib/fuzzystrmatch/README.soundex25 Jan 2005 07:16:41 -
***
*** 7,21 
--- 7,31 
  beyond English names (or the English pronunciation of names), and
  it is not a linguistic tool.
  
+ When comparing two soundex values to determine similarity, the
+ difference function reports how close the match is on a scale
+ from zero to four, with zero being no match and four being an
+ exact match.
+ 
  The following are some usage examples:
  
  SELECT soundex('hello world!');
  
+ SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');
+ SELECT soundex('Anne'), soundex('Andrew'), difference('Anne', 'Andrew');
+ SELECT soundex('Anne'), soundex('Margaret'), difference('Anne', 'Margaret');
+ 
  CREATE TABLE s (nm text)\g
  
  insert into s values ('john')\g
  insert into s values ('joan')\g
  insert into s values ('wobbly')\g
+ insert into s values ('jack')\g
  
  select * from s
  where soundex(nm) = soundex('john')\g
***
*** 58,62 
  WHERE text_sx_eq(nm,'john')\g
  
  SELECT *
! from s
! where s.nm #= 'john';
--- 68,77 
  WHERE text_sx_eq(nm,'john')\g
  
  SELECT *
! FROM s
! WHERE s.nm #= 'john';
! 
! SELECT *
! FROM s
! WHERE difference(s.nm, 'john')  2;
! 
Index: contrib/fuzzystrmatch/fuzzystrmatch.c
===
RCS file: /projects/cvsroot/pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v
retrieving revision 1.14
diff -c -r1.14 fuzzystrmatch.c
*** contrib/fuzzystrmatch/fuzzystrmatch.c   1 Jan 2005 05:43:06 -   
1.14
--- contrib/fuzzystrmatch/fuzzystrmatch.c   25 Jan 2005 07:16:41 -
***
*** 755,757 
--- 755,777 
++count;
}
  }
+ 
+ PG_FUNCTION_INFO_V1(difference);
+ 
+ Datum
+ difference(PG_FUNCTION_ARGS)
+ {
+   char 

Re: [PATCHES] add soundex difference function to

2005-01-24 Thread Neil Conway
On Tue, 2005-01-25 at 02:26 -0500, Kris Jurka wrote:
 Yes, it should, and even more importantly strict because it crashes when
 called with null inputs.  I copied this off the adjacent entry without
 thinking about it.  So currently SELECT text_soundex(NULL); crashes the
 server.

Ah, good catch. I remember checking all the builtin functions for
crashes on NULL input; it would be worth doing the same for contrib/.

Barring any objections, I'll apply the full patch to HEAD and the crash
fix to REL8_0_STABLE and REL7_4_STABLE tomorrow.

-Neil



---(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] pg_autovacuum Win32 Service startup delay

2005-01-24 Thread Tom Lane
Matthew T. O'Connor matthew@zeut.net writes:
 In the windows service world, is there any reason pg_autovacuum should 
 ever give up?

I was a bit worried about the scenario in which J Random Luser tries to
start the server twice and ends up with two autovacuum daemons attached
to the same postmaster.  I'm not sure if this is possible, probable,
or dangerous ... but it seems like a point to consider.

regards, tom lane

---(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