[PATCHES] SIGPIPE handling, take two.

2003-11-02 Thread Manfred Spraul
pqsecure_write tries to catch SIGPIPE signals generated by network 
disconnects by setting the signal handler to SIG_IGN. The current 
approach causes several problems:
- it always sets SA_RESTART when it restores the old handler.
- it's not reliable for multi threaded apps, because another thread 
could change the signal handler inbetween.
- it's slow, because after setting a signal handler to SIG_IGN the 
kernel must enumerate all threads and clear all pending signals (at 
least FreeBSD-5.1 and linux-2.6 do that. Earlier linux kernels don't - 
their signal handling is known to be broken for multithreaded apps).

Initially I proposed a new option for PQconnectdb, but Tom didn't like 
that. The attached patch autodetects if it should set the signal 
handler, Tom proposed that. The code doesn't try to check if the signal 
is "handled" by blocking it, because I haven't figured out how to check 
that: sigprocmask is undefined for multithreaded apps and calling 
pthread_sigmask would force every libpq user to link against libpthread.

--
   Manfred
? src/interfaces/libpq/libpq.so.3.1
Index: src/interfaces/libpq/fe-connect.c
===
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.263
diff -c -r1.263 fe-connect.c
*** src/interfaces/libpq/fe-connect.c   18 Oct 2003 05:02:06 -  1.263
--- src/interfaces/libpq/fe-connect.c   2 Nov 2003 18:29:40 -
***
*** 41,46 
--- 41,47 
  #include 
  #endif
  #include 
+ #include 
  #endif
  
  #include "libpq/ip.h"
***
*** 951,956 
--- 952,983 
else if (conn->sslmode[0] == 'a')   /* "allow" */
conn->wait_ssl_try = true;
  #endif
+   /* 
+* Autodetect SIGPIPE signal handling:
+* The default action per Unix spec is kill current process and
+* that's not acceptable. If the current setting is not the default,
+* then assume that the caller knows what he's doing and leave the
+* signal handler unchanged. Otherwise set the signal handler to
+* SIG_IGN around each send() syscall. Unfortunately this is both
+* unreliable and slow for multithreaded apps.
+*/
+   conn->do_sigaction = true;
+ #if !defined(HAVE_POSIX_SIGNALS)
+   {
+   pqsigfunc old;
+   old = signal(SIGPIPE, SIG_IGN);
+   if (old != SIG_DFL)
+   conn->do_sigaction = false;
+   signal(SIGPIPE, old);
+   }
+ #else
+   {
+   struct sigaction oact;
+ 
+   if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_DFL)
+   conn->do_sigaction = false;
+   }
+ #endif   /* !HAVE_POSIX_SIGNALS */
  
/*
 * Set up to try to connect, with protocol 3.0 as the first attempt.
Index: src/interfaces/libpq/fe-secure.c
===
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
retrieving revision 1.32
diff -c -r1.32 fe-secure.c
*** src/interfaces/libpq/fe-secure.c29 Sep 2003 16:38:04 -  1.32
--- src/interfaces/libpq/fe-secure.c2 Nov 2003 18:29:41 -
***
*** 348,354 
ssize_t n;
  
  #ifndef WIN32
!   pqsigfunc   oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
  #endif
  
  #ifdef USE_SSL
--- 348,357 
ssize_t n;
  
  #ifndef WIN32
!   pqsigfunc   oldsighandler = NULL;
! 
!   if (conn->do_sigaction)
!   oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
  #endif
  
  #ifdef USE_SSL
***
*** 408,414 
n = send(conn->sock, ptr, len, 0);
  
  #ifndef WIN32
!   pqsignal(SIGPIPE, oldsighandler);
  #endif
  
return n;
--- 411,418 
n = send(conn->sock, ptr, len, 0);
  
  #ifndef WIN32
!   if (conn->do_sigaction)
!   pqsignal(SIGPIPE, oldsighandler);
  #endif
  
return n;
Index: src/interfaces/libpq/libpq-int.h
===
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.82
diff -c -r1.82 libpq-int.h
*** src/interfaces/libpq/libpq-int.h5 Sep 2003 02:08:36 -   1.82
--- src/interfaces/libpq/libpq-int.h2 Nov 2003 18:29:42 -
***
*** 329,334 
--- 329,335 
charpeer_dn[256 + 1];   /* peer distinguished name */
charpeer_cn[SM_USER + 1];   /* peer common name */
  #endif
+   booldo_sigaction;   /* set SIGPIPE to SIG_IGN around every send() 
call */
  
/* Buffer for current error message */
PQExpBufferData errorMessage;   /* expansible string */

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


[PATCHES] psql: \dg and groups for \du

2003-11-02 Thread Markus Bertheau
Hi,

attached is a patch that adds display of the groups a user belongs to to
\du and a \dg command to psql. It's against 7.4beta5.

-- 
Markus Bertheau <[EMAIL PROTECTED]>
diff -ru postgresql-7.4beta5.orig/src/bin/psql/command.c postgresql-7.4beta5/src/bin/psql/command.c
--- postgresql-7.4beta5.orig/src/bin/psql/command.c	2003-10-11 20:04:26.0 +0200
+++ postgresql-7.4beta5/src/bin/psql/command.c	2003-11-02 19:31:27.0 +0100
@@ -363,6 +363,9 @@
 			case 'f':
 success = describeFunctions(pattern, show_verbose);
 break;
+			case 'g':
+success = describeGroups(pattern);
+break;
 			case 'l':
 success = do_lo_list();
 break;
diff -ru postgresql-7.4beta5.orig/src/bin/psql/describe.c postgresql-7.4beta5/src/bin/psql/describe.c
--- postgresql-7.4beta5.orig/src/bin/psql/describe.c	2003-10-17 02:57:04.0 +0200
+++ postgresql-7.4beta5/src/bin/psql/describe.c	2003-11-02 19:38:31.0 +0100
@@ -1272,12 +1272,13 @@
 			"   WHEN u.usesuper THEN CAST('%s' AS pg_catalog.text)\n"
 		 "   WHEN u.usecreatedb THEN CAST('%s' AS pg_catalog.text)\n"
 	  "   ELSE CAST('' AS pg_catalog.text)\n"
-	  "  END AS \"%s\"\n"
+	  "  END AS \"%s\",\n"
+	  "  ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as \"%s\"\n"
 	  "FROM pg_catalog.pg_user u\n",
 	  _("User name"), _("User ID"),
 	  _("superuser, create database"),
 	  _("superuser"), _("create database"),
-	  _("Attributes"));
+	  _("Attributes"), _("Groups"));
 
 	processNamePattern(&buf, pattern, false, false,
 	   NULL, "u.usename", NULL, NULL);
@@ -1300,6 +1301,46 @@
 
 
 /*
+ * \dg
+ *
+ * Describes groups.
+ */
+bool
+describeGroups(const char *pattern)
+{
+	PQExpBufferData buf;
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf,
+	  "SELECT g.groname AS \"%s\",\n"
+	  "  g.grosysid AS \"%s\"\n"
+	  "FROM pg_catalog.pg_group g\n",
+	  _("Group name"), _("Group ID"));
+
+	processNamePattern(&buf, pattern, false, false,
+	   NULL, "g.groname", NULL, NULL);
+
+	appendPQExpBuffer(&buf, "ORDER BY 1;");
+
+	res = PSQLexec(buf.data, false);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	myopt.nullPrint = NULL;
+	myopt.title = _("List of database groups");
+
+	printQuery(res, &myopt, pset.queryFout);
+
+	PQclear(res);
+	return true;
+}
+
+
+/*
  * listTables()
  *
  * handler for \d, \dt, etc.
diff -ru postgresql-7.4beta5.orig/src/bin/psql/describe.h postgresql-7.4beta5/src/bin/psql/describe.h
--- postgresql-7.4beta5.orig/src/bin/psql/describe.h	2003-08-05 01:59:40.0 +0200
+++ postgresql-7.4beta5/src/bin/psql/describe.h	2003-11-02 19:31:27.0 +0100
@@ -25,6 +25,9 @@
 /* \du */
 bool		describeUsers(const char *pattern);
 
+/* \dg */
+bool		describeGroups(const char *pattern);
+
 /* \z (or \dp) */
 bool		permissionsList(const char *pattern);
 
diff -ru postgresql-7.4beta5.orig/src/bin/psql/help.c postgresql-7.4beta5/src/bin/psql/help.c
--- postgresql-7.4beta5.orig/src/bin/psql/help.c	2003-10-02 08:39:31.0 +0200
+++ postgresql-7.4beta5/src/bin/psql/help.c	2003-11-02 19:31:27.0 +0100
@@ -216,6 +216,7 @@
 	fprintf(output, _("  \\dd [PATTERN]  show comment for object\n"));
 	fprintf(output, _("  \\dD [PATTERN]  list domains\n"));
 	fprintf(output, _("  \\df [PATTERN]  list functions (add \"+\" for more detail)\n"));
+	fprintf(output, _("  \\dg [PATTERN]  list groups\n"));
 	fprintf(output, _("  \\dn [PATTERN]  list schemas\n"));
 	fprintf(output, _("  \\do [NAME] list operators\n"));
 	fprintf(output, _("  \\dllist large objects, same as \\lo_list\n"));
diff -ru postgresql-7.4beta5.orig/src/bin/psql/tab-complete.c postgresql-7.4beta5/src/bin/psql/tab-complete.c
--- postgresql-7.4beta5.orig/src/bin/psql/tab-complete.c	2003-10-17 13:52:06.0 +0200
+++ postgresql-7.4beta5/src/bin/psql/tab-complete.c	2003-11-02 19:32:40.0 +0100
@@ -614,7 +614,7 @@
 
 	static char *backslash_commands[] = {
 		"\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright",
-		"\\d", "\\da", "\\dc", "\\dC", "\\dd", "\\dD", "\\df", "\\di",
+		"\\d", "\\da", "\\dc", "\\dC", "\\dd", "\\dD", "\\df", "\\dg", "\\di",
 		"\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT",
 		"\\dv", "\\du",
 		"\\e", "\\echo", "\\encoding",

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

   http://archives.postgresql.org


[PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman
Since peter objects to my methods, what is an ACCEPTABLE way to detect
the 7.1.3UP3 compiler?
I'd like to get this fixed for RC1.

LER

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


pgp0.pgp
Description: PGP signature


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Peter Eisentraut
Larry Rosenman writes:

> Since peter objects to my methods, what is an ACCEPTABLE way to detect
> the 7.1.3UP3 compiler?

One POSSIBLE way to do this properly is to write a test that

1) Uses $CC, $CFLAGS, and related variables rather than hardcoding 'cc -O'.

2) Names any test files conftest.*, so configure cleans up automatically.

3) Doesn't execute any compiled programs.  See the __FAST_MATH__ test for
   an example.

However, I still think that we should not bother testing for this.
Considering that the condition first occurred a couple of months ago and
is already fixed, this isn't a big issue.  Think about what would happen
if we had to develop and maintain fixes for every buggy GCC compiler every
released.

-- 
Peter Eisentraut   [EMAIL PROTECTED]


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


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman


--On Sunday, November 02, 2003 22:26:40 +0100 Peter Eisentraut 
<[EMAIL PROTECTED]> wrote:

Larry Rosenman writes:

Since peter objects to my methods, what is an ACCEPTABLE way to detect
the 7.1.3UP3 compiler?
One POSSIBLE way to do this properly is to write a test that

1) Uses $CC, $CFLAGS, and related variables rather than hardcoding 'cc
-O'.
2) Names any test files conftest.*, so configure cleans up automatically.

3) Doesn't execute any compiled programs.  See the __FAST_MATH__ test for
   an example.
However, I still think that we should not bother testing for this.
Considering that the condition first occurred a couple of months ago and
is already fixed, this isn't a big issue.  Think about what would happen
if we had to develop and maintain fixes for every buggy GCC compiler every
released.
The problem is MOST people will **NOT** be able to get the fixed compiler
as it's on the Upgrade Pack path (PAY FOR), and **NOT** the Maintenance
Pack path (Free).
I'll try and write the patch as you suggest.


--
Peter Eisentraut   [EMAIL PROTECTED]


--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


pgp0.pgp
Description: PGP signature


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Peter Eisentraut
Larry Rosenman writes:

> The problem is MOST people will **NOT** be able to get the fixed compiler
> as it's on the Upgrade Pack path (PAY FOR), and **NOT** the Maintenance
> Pack path (Free).

Why did they upgrade to the broken compiler in the first place, and why
doesn't SCO provide free fixes for broken products?

-- 
Peter Eisentraut   [EMAIL PROTECTED]


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


Re: [PATCHES] "make check" improvement for cygwin

2003-11-02 Thread Tom Lane
"Andrew Dunstan" <[EMAIL PROTECTED]> writes:
> Well, I posted the note last night but I finished the patch today, because
> it was very simple and took so little time.

I've committed this with the later revision about the warning message,
and some other minor cleanups.  I added documentation in the "Regression
Tests" chapter, but if there is anyplace else you want to mention it,
send in a docs patch.

regards, tom lane

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

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman


--On Sunday, November 02, 2003 23:05:21 +0100 Peter Eisentraut 
<[EMAIL PROTECTED]> wrote:

Larry Rosenman writes:

The problem is MOST people will **NOT** be able to get the fixed compiler
as it's on the Upgrade Pack path (PAY FOR), and **NOT** the Maintenance
Pack path (Free).
Why did they upgrade to the broken compiler in the first place, and why
doesn't SCO provide free fixes for broken products?
The "Broken Compiler" is in EVERY version prior to the UP3 compiler.  We 
just started tripping it with the changes in 7.4.

I don't know why they didn't/haven't put this fix in the MP path, and I 
can't change that decision, therefore, we need to work around it.

It's not that big of a deal.  See the patch I posted that SHOULD meet your
requirements.

--
Peter Eisentraut   [EMAIL PROTECTED]


--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


pgp0.pgp
Description: PGP signature


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman


--On Sunday, November 02, 2003 15:29:37 -0600 Larry Rosenman 
<[EMAIL PROTECTED]> wrote:


I'll try and write the patch as you suggest.
Here's a patch as you suggested:

Index: src/template/unixware
===
RCS file: /projects/cvsroot/pgsql-server/src/template/unixware,v
retrieving revision 1.27
diff -u -r1.27 unixware
--- src/template/unixware   25 Oct 2003 15:32:11 -  1.27
+++ src/template/unixware   2 Nov 2003 21:53:33 -
@@ -1,13 +1,27 @@
if test "$GCC" = yes; then
  THREAD_CPPFLAGS="-pthread"
else
-# the -Kno_host is temporary for a bug in the compiler.  See -hackers
+# the -Kno_host is for a bug in the compiler.  See -hackers
# discussion on 7-8/Aug/2003.
-# when the 7.1.3UP3 or later compiler is out, we can do a version check.
-  CFLAGS="-O -Kinline,no_host"
+# version check for the 7.1.3UP3 compiler (version 401200310):
+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+#if __SCO_VERSION__ >= 401200310
+#error good compiler
+#else
+#error bad compiler
+#endif
+__EOF__
+  $CC conftest.c 2>conftest.err 1>&2
+  grep -q good conftest.err
+  if test $? = 0; then
+CFLAGS="-O -Kinline"
+  else
+CFLAGS="-O -Kinline,no_host"
+  fi
+  rm conftest.*
  THREAD_CPPFLAGS="-K pthread"
fi
-
THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no # verified 7.1.3 2003-09-03
THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


unixware.up3.patch2
Description: Binary data


pgp0.pgp
Description: PGP signature


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Tom Lane
Larry Rosenman <[EMAIL PROTECTED]> writes:
> +# version check for the 7.1.3UP3 compiler (version 401200310):
> +cat >conftest.c <<__EOF__
> +int main(int argc, char **argv)
> +#if __SCO_VERSION__ >=3D 401200310
> +#error good compiler
> +#else
> +#error bad compiler
> +#endif
> +__EOF__
> +  $CC conftest.c 2>conftest.err 1>&2
> +  grep -q good conftest.err
> +  if test $? =3D 0; then
> +CFLAGS=3D"-O -Kinline"
> +  else
> +CFLAGS=3D"-O -Kinline,no_host"
> +  fi

Couldn't this be simplified to

+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+{
+#if __SCO_VERSION__ < 401200310
+#error bad compiler
+#endif
+}
+__EOF__
+  $CC conftest.c >/dev/null 2>&1
+  if test $? = 0; then
+CFLAGS="-O -Kinline"
+  else
+CFLAGS="-O -Kinline,no_host"
+  fi

regards, tom lane

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


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman


--On Sunday, November 02, 2003 18:17:26 -0500 Tom Lane <[EMAIL PROTECTED]> 
wrote:

Larry Rosenman <[EMAIL PROTECTED]> writes:
+# version check for the 7.1.3UP3 compiler (version 401200310):
+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+#if __SCO_VERSION__ >=3D 401200310
+#error good compiler
+#else
+#error bad compiler
+#endif
+__EOF__
+  $CC conftest.c 2>conftest.err 1>&2
+  grep -q good conftest.err
+  if test $? =3D 0; then
+CFLAGS=3D"-O -Kinline"
+  else
+CFLAGS=3D"-O -Kinline,no_host"
+  fi
Couldn't this be simplified to

+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+{
+#if __SCO_VERSION__ < 401200310
+#error bad compiler
+#endif
+}
+__EOF__
+  $CC conftest.c >/dev/null 2>&1
+  if test $? = 0; then
+CFLAGS="-O -Kinline"
+  else
+CFLAGS="-O -Kinline,no_host"
+  fi
			regards, tom lane
How about this?  ( I needed to make it valid C):

Index: src/template/unixware
===
RCS file: /projects/cvsroot/pgsql-server/src/template/unixware,v
retrieving revision 1.27
diff -u -r1.27 unixware
--- src/template/unixware   25 Oct 2003 15:32:11 -  1.27
+++ src/template/unixware   2 Nov 2003 23:22:21 -
@@ -1,13 +1,27 @@
if test "$GCC" = yes; then
  THREAD_CPPFLAGS="-pthread"
else
-# the -Kno_host is temporary for a bug in the compiler.  See -hackers
+# the -Kno_host is for a bug in the compiler.  See -hackers
# discussion on 7-8/Aug/2003.
-# when the 7.1.3UP3 or later compiler is out, we can do a version check.
-  CFLAGS="-O -Kinline,no_host"
+# version check for the 7.1.3UP3 compiler (version 401200310):
+cat >conftest.c <<__EOF__
+#if __SCO_VERSION__ < 401200310
+#error bad compiler
+#endif
+int main(int argc,char **argv)
+{
+}
+
+__EOF__
+  $CC conftest.c >/dev/null 2>&1
+  if test $? = 0; then
+CFLAGS="-O -Kinline"
+  else
+CFLAGS="-O -Kinline,no_host"
+  fi
+  rm conftest.*
  THREAD_CPPFLAGS="-K pthread"
fi
-
THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no # verified 7.1.3 2003-09-03
THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"


--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


unixware.up3.patch3
Description: Binary data


pgp0.pgp
Description: PGP signature


Re: [PATCHES] UW 713UP3 patch

2003-11-02 Thread Larry Rosenman


--On Sunday, November 02, 2003 17:23:59 -0600 Larry Rosenman 
<[EMAIL PROTECTED]> wrote:



--On Sunday, November 02, 2003 18:17:26 -0500 Tom Lane
<[EMAIL PROTECTED]> wrote:
Larry Rosenman <[EMAIL PROTECTED]> writes:
+# version check for the 7.1.3UP3 compiler (version 401200310):
+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+#if __SCO_VERSION__ >=3D 401200310
+#error good compiler
+#else
+#error bad compiler
+#endif
+__EOF__
+  $CC conftest.c 2>conftest.err 1>&2
+  grep -q good conftest.err
+  if test $? =3D 0; then
+CFLAGS=3D"-O -Kinline"
+  else
+CFLAGS=3D"-O -Kinline,no_host"
+  fi
Couldn't this be simplified to

+cat >conftest.c <<__EOF__
+int main(int argc, char **argv)
+{
+#if __SCO_VERSION__ < 401200310
+#error bad compiler
+#endif
+}
+__EOF__
+  $CC conftest.c >/dev/null 2>&1
+  if test $? = 0; then
+CFLAGS="-O -Kinline"
+  else
+CFLAGS="-O -Kinline,no_host"
+  fi
			regards, tom lane
How about this?  ( I needed to make it valid C):
OOOPPPSS.  Yes, Tom, yours will work just fine.

I missed the fact that you put the #if inside the braces.

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


pgp0.pgp
Description: PGP signature


Re: [PATCHES] "make check" improvement for cygwin

2003-11-02 Thread Andrew Dunstan


Tom Lane wrote:

"Andrew Dunstan" <[EMAIL PROTECTED]> writes:
 

Well, I posted the note last night but I finished the patch today, because
it was very simple and took so little time.
   

I've committed this with the later revision about the warning message,
and some other minor cleanups.  I added documentation in the "Regression
Tests" chapter, but if there is anyplace else you want to mention it,
send in a docs patch.
 

Thanks, Tom! I just sat down to do this work and saw your note.

This looks fine - the only other place it needs to be mentioned is in 
FAQ_MSWIN I think.

patch for that attached.

cheers

andrew
Index: FAQ_MSWIN
===
RCS file: /projects/cvsroot/pgsql-server/doc/FAQ_MSWIN,v
retrieving revision 1.15
diff -c -w -r1.15 FAQ_MSWIN
*** FAQ_MSWIN   11 Nov 2002 20:04:05 -  1.15
--- FAQ_MSWIN   3 Nov 2003 03:50:09 -
***
*** 51,56 
  
  2.  make check can generate spurious regression test failures due to
  overflowing the listen() backlog queue which causes connection
! refused errors.
  
  Problem reports can be sent to [EMAIL PROTECTED]
--- 51,59 
  
  2.  make check can generate spurious regression test failures due to
  overflowing the listen() backlog queue which causes connection
! refused errors or hangs. You can limit the number of connections 
! using the MAX_CONNECTIONS option thus:
!   make MAX_CONNECTIONS=5 check
! (on some systems you can have up to about 10 simultaneous connections).
  
  Problem reports can be sent to [EMAIL PROTECTED]

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


[PATCHES] Two very minor win32 patches

2003-11-02 Thread Claudio Natoli
For src/backend/postmaster/postmaster.c and src/include/c.h
(Note: should ioctlsocket_ret be initialized to 1 for BEOS too, and can it
take an unsigned parameter? If so, could simplify.)





--- 
WE HAVE MOVED - PLEASE NOTE OUR NEW CONTACT DETAILS: 
THE BASEMENT, 33 EWELL STREET, BALMAIN NSW 2041 
TEL: +61 2 9555 1544 FAX: +61 2 9555 6911 
Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see 
http://www.memetrics.com/emailpolicy.html


Index: src/backend/postmaster/postmaster.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.341.2.1
diff -c -2 -r1.341.2.1 postmaster.c
*** src/backend/postmaster/postmaster.c 7 Sep 2003 04:36:53 -   1.341.2.1
--- src/backend/postmaster/postmaster.c 3 Nov 2003 05:09:26 -
***
*** 215,221 
  
  /* For FNCTL_NONBLOCK */
! #if defined(WIN32) || defined(__BEOS__)
  long  ioctlsocket_ret;
  #endif
  
  /* list of library:init-function to be preloaded */
--- 215,225 
  
  /* For FNCTL_NONBLOCK */
! #if defined(WIN32)
! unsigned long ioctlsocket_ret = 1;
! #endif
! #if defined(__BEOS__)
  long  ioctlsocket_ret;
  #endif
+ 
  
  /* list of library:init-function to be preloaded */
Index: src/include/c.h
===
RCS file: /projects/cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.152
diff -c -2 -r1.152 c.h
*** src/include/c.h 4 Aug 2003 02:40:10 -   1.152
--- src/include/c.h 3 Nov 2003 05:12:10 -
***
*** 707,717 
  #define FCNTL_NONBLOCK(sock)  fcntl(sock, F_SETFL, O_NONBLOCK)
  #else
- extern long ioctlsocket_ret;
  
  /* Returns non-0 on failure, while fcntl() returns -1 on failure */
  #ifdef WIN32
  #define FCNTL_NONBLOCK(sock)  ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 
0 : -1)
  #endif
  #ifdef __BEOS__
  #define FCNTL_NONBLOCK(sock)  ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : 
-1)
  #endif
--- 707,718 
  #define FCNTL_NONBLOCK(sock)  fcntl(sock, F_SETFL, O_NONBLOCK)
  #else
  
  /* Returns non-0 on failure, while fcntl() returns -1 on failure */
  #ifdef WIN32
+  extern unsigned long ioctlsocket_ret;
  #define FCNTL_NONBLOCK(sock)  ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 
0 : -1)
  #endif
  #ifdef __BEOS__
+  extern long ioctlsocket_ret;
  #define FCNTL_NONBLOCK(sock)  ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : 
-1)
  #endif

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


[PATCHES] Win32 patch for Makefile.shlib

2003-11-02 Thread Claudio Natoli

If this is acceptable, I'll send a similar one for src/backend/Makefile

Cheers,
Claudio


--- 
WE HAVE MOVED - PLEASE NOTE OUR NEW CONTACT DETAILS: 
THE BASEMENT, 33 EWELL STREET, BALMAIN NSW 2041 
TEL: +61 2 9555 1544 FAX: +61 2 9555 6911 
Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see 
http://www.memetrics.com/emailpolicy.html
  

Index: src/Makefile.shlib
===
RCS file: /projects/cvsroot/pgsql-server/src/Makefile.shlib,v
retrieving revision 1.67
diff -w -c -2 -r1.67 Makefile.shlib
*** src/Makefile.shlib  21 Mar 2003 17:18:34 -  1.67
--- src/Makefile.shlib  3 Nov 2003 05:42:53 -
***
*** 199,202 
--- 199,206 
  endif
  
+ ifeq ($(PORTNAME), win32)
+   shlib   := lib$(NAME)$(DLSUFFIX)
+ endif
+ 
  ifeq ($(PORTNAME), beos)
shlib   := lib$(NAME)$(DLSUFFIX)
***
*** 227,230 
--- 231,235 
  
  ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
  
  ifndef LORDER
***
*** 240,243 
--- 245,249 
$(RANLIB) $@
  
+ endif # not win32
  endif # not cygwin
  
***
*** 246,249 
--- 252,256 
  ifneq ($(PORTNAME), beos)
  ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
  ifneq ($(PORTNAME), aix)
  
***
*** 271,274 
--- 278,291 
  endif # PORTNAME == aix
  
+ else # PORTNAME == win32
+ 
+ # win32 case
+ $(shlib) lib$(NAME).a: $(OBJS)
+   $(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
+   $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) 
$(SHLIB_LINK)
+   $(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
+ 
+ endif # PORTNAME == win32
+ 
  else # PORTNAME == cygwin
  
***
*** 310,313 
--- 327,331 
$(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
  ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
  ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
cd $(DESTDIR)$(libdir) && \
***
*** 321,324 
--- 339,343 
  endif
  
+ endif # not win32
  endif # not cygwin
  endif # enable_shared
***
*** 353,356 
--- 372,379 
  endif
  ifeq ($(PORTNAME), cygwin)
+   rm -f $(NAME).dll $(NAME).def
+ endif
+ 
+ ifeq ($(PORTNAME), win32)
rm -f $(NAME).dll $(NAME).def
  endif

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


[PATCHES] bufmgr code cleanup

2003-11-02 Thread Neil Conway
This patch cleans up some of the bufmgr code:

- replace uses of

LockBuffer(buf, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buf);

  with the equivalent, but more concise:

UnlockAndReleaseBuffer(buf);

- analogous changes were made by replacing LockBuffer() + WriteBuffer()
with UnlockAndWriteBuffer()

- remove a bunch of #ifdef BMTRACE code, since it was ugly and broken
anyway

- remove an unused buffer descriptor bit flag (BM_PRIVATE)

- move the definition of INVALID_DESCRIPTOR to out of bufmgr.h and into
freelist.c, since it is the only file that uses it

- remove another unused function, and fix a few comments

Please apply to the CVS HEAD.

-Neil

Index: src/backend/access/hash/hashpage.c
===
RCS file: /var/lib/cvs/pgsql-server/src/backend/access/hash/hashpage.c,v
retrieving revision 1.42
diff -c -r1.42 hashpage.c
*** src/backend/access/hash/hashpage.c	4 Sep 2003 22:06:27 -	1.42
--- src/backend/access/hash/hashpage.c	31 Oct 2003 22:55:59 -
***
*** 135,142 
  void
  _hash_relbuf(Relation rel, Buffer buf)
  {
! 	LockBuffer(buf, BUFFER_LOCK_UNLOCK);
! 	ReleaseBuffer(buf);
  }
  
  /*
--- 135,141 
  void
  _hash_relbuf(Relation rel, Buffer buf)
  {
! 	UnlockAndReleaseBuffer(buf);
  }
  
  /*
***
*** 166,173 
  void
  _hash_wrtbuf(Relation rel, Buffer buf)
  {
! 	LockBuffer(buf, BUFFER_LOCK_UNLOCK);
! 	WriteBuffer(buf);
  }
  
  /*
--- 165,171 
  void
  _hash_wrtbuf(Relation rel, Buffer buf)
  {
! 	UnlockAndWriteBuffer(buf);
  }
  
  /*
Index: src/backend/access/heap/heapam.c
===
RCS file: /var/lib/cvs/pgsql-server/src/backend/access/heap/heapam.c,v
retrieving revision 1.157
diff -c -r1.157 heapam.c
*** src/backend/access/heap/heapam.c	1 Oct 2003 21:30:52 -	1.157
--- src/backend/access/heap/heapam.c	31 Oct 2003 22:59:14 -
***
*** 899,906 
  	 */
  	if (!ItemIdIsUsed(lp))
  	{
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		*userbuf = InvalidBuffer;
  		tuple->t_datamcxt = NULL;
  		tuple->t_data = NULL;
--- 899,905 
  	 */
  	if (!ItemIdIsUsed(lp))
  	{
! 		UnlockAndReleaseBuffer(buffer);
  		*userbuf = InvalidBuffer;
  		tuple->t_datamcxt = NULL;
  		tuple->t_data = NULL;
***
*** 1006,1013 
  	}
  	if (invalidBlock)
  	{
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		return NULL;
  	}
  
--- 1005,1011 
  	}
  	if (invalidBlock)
  	{
! 		UnlockAndReleaseBuffer(buffer);
  		return NULL;
  	}
  
***
*** 1033,1040 
  		!ItemPointerEquals(tid, &ctid))
  		linkend = false;
  
! 	LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 	ReleaseBuffer(buffer);
  
  	if (!valid)
  	{
--- 1031,1037 
  		!ItemPointerEquals(tid, &ctid))
  		linkend = false;
  
! 	UnlockAndReleaseBuffer(buffer);
  
  	if (!valid)
  	{
***
*** 1174,1181 
  
  	END_CRIT_SECTION();
  
! 	LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 	WriteBuffer(buffer);
  
  	/*
  	 * If tuple is cachable, mark it for invalidation from the caches in
--- 1171,1177 
  
  	END_CRIT_SECTION();
  
! 	UnlockAndWriteBuffer(buffer);
  
  	/*
  	 * If tuple is cachable, mark it for invalidation from the caches in
***
*** 1253,1260 
  
  	if (result == HeapTupleInvisible)
  	{
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		elog(ERROR, "attempted to delete invisible tuple");
  	}
  	else if (result == HeapTupleBeingUpdated && wait)
--- 1249,1255 
  
  	if (result == HeapTupleInvisible)
  	{
! 		UnlockAndReleaseBuffer(buffer);
  		elog(ERROR, "attempted to delete invisible tuple");
  	}
  	else if (result == HeapTupleBeingUpdated && wait)
***
*** 1301,1308 
  			   result == HeapTupleUpdated ||
  			   result == HeapTupleBeingUpdated);
  		*ctid = tp.t_data->t_ctid;
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		return result;
  	}
  
--- 1296,1302 
  			   result == HeapTupleUpdated ||
  			   result == HeapTupleBeingUpdated);
  		*ctid = tp.t_data->t_ctid;
! 		UnlockAndReleaseBuffer(buffer);
  		return result;
  	}
  
***
*** 1483,1490 
  
  	if (result == HeapTupleInvisible)
  	{
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		elog(ERROR, "attempted to update invisible tuple");
  	}
  	else if (result == HeapTupleBeingUpdated && wait)
--- 1477,1483 
  
  	if (result == HeapTupleInvisible)
  	{
! 		UnlockAndReleaseBuffer(buffer);
  		elog(ERROR, "attempted to update invisible tuple");
  	}
  	else if (result == HeapTupleBeingUpdated && wait)
***
*** 1531,1538 
  			   result == HeapTupleUpdated ||
  			   result == HeapTupleBeingUpdated);
  		*ctid = oldtup.t_data->t_ctid;
! 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
! 		ReleaseBuffer(buffer);
  		return result;
  	}
  
--- 1524,1530