Re: [PATCHES] Fix for initdb failures on Vista

2008-02-27 Thread Magnus Hagander
On Thu, Feb 21, 2008 at 03:02:07PM +, Dave Page wrote:
 The attached patch fixes problems reported primarily on Vista, but
 also on some Windows 2003 and XP installations in which initdb reports
 that it cannot find postgres.exe.
 
 This occurs because of security-related changes implemented in Windows
 Vista and recent patches on older OS's. When running initdb or pg_ctl
 we currently create a restricted security token with the
 Administrators and Power Users groups (and thus their privileges)
 removed and re-execute the same program using the restricted token.
 This ensures that the process is run without potentially dangerous
 privileges no matter what user account it was started from. On Vista
 and friends however, the default DACL (list of Access Control Entries)
 used in the restricted token contains Administrators (the group) 
 System when we run as Administrator, vs. User + System when run as
 other users. Because we then drop Administrators, we are left with
 only the System ACE in the DACL, which does not allow us to use
 CreatePipe()/CreateProcess().
 
 To fix this, when we create the restricted process, we initially start
 it in suspended mode. We modify it's DACL to explicitly add an ACE for
 the current user, and then resume the child process. This remains
 secure because administrative privileges are granted to the groups
 that we've dropped, not the user itself.
 
 I've tested on Vista and XP, but additional testing would be useful
 (Andrew, Magnus?). Please apply to head, 8.3 and 8.2

Other than Heikkis comments:

We obviously need to test-build on mingw, so if someone can do that, pleae
do. If not, I'll try to get my VM up and running on it (since mingw doesn't
work on my win64 box).

I'm also a bit concerned that there is a whole lot of failure cases in
AddUserToDacl() that all return the same, thus making it impossible to
track down a problem in this code. Given that it's fairly complex
interactions with the API, I think we'll want to add actual error messages
to the individual failure cases. Thoughts?

//Magnus

---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate


Re: [PATCHES] Fix for initdb failures on Vista

2008-02-27 Thread Andrew Dunstan



Magnus Hagander wrote:

I've tested on Vista and XP, but additional testing would be useful
(Andrew, Magnus?). Please apply to head, 8.3 and 8.2



Other than Heikkis comments:

We obviously need to test-build on mingw, so if someone can do that, pleae
do. If not, I'll try to get my VM up and running on it (since mingw doesn't
work on my win64 box).


  


I'll look at testing mingw on my 32bit Vista box.

cheers

andrew

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


[PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Robert Lor
Please find the patch attached per this thread 
http://archives.postgresql.org/pgsql-hackers/2008-02/msg00912.php


Notes to committer.

1) Please remove src/include/pg_trace.h as it's no longer needed

2) Need help figuring out how to copy src/backend/util/probes.d from src 
tree to
bld tree at build time. It works fine if compilation is done in the src 
tree.


3) Note on src/backend/Makefile
  The current rule below does not work. After expansion, utils/probes.d 
needs
  to come right after -s, but currently it shows up at the end after 
all the .o files.


  utils/probes.o: utils/probes.d $(SUBDIROBJS)
  $(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@

 The following works, but I think the correct way is to include 
probes.d as a
 dependency and have it show up after -s. I couldn't get it to work 
this way with

 my somewhat limited knowledge of makefiles.

 utils/probes.o: $(SUBDIROBJS)
  $(DTRACE) $(DTRACEFLAGS) -G -s $(srcdir)/utils/probes.d -o $@ 
$(call expand_subsys,$^)



Regards,
-Robert

? src/include/probes_null.h
Index: src/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/Makefile,v
retrieving revision 1.42
diff -c -r1.42 Makefile
*** src/Makefile	21 Aug 2007 01:11:12 -	1.42
--- src/Makefile	27 Feb 2008 03:22:55 -
***
*** 14,19 
--- 14,22 
  
  
  all install installdirs uninstall distprep:
+ ifeq ($(enable_dtrace), yes)
+ 	$(DTRACE) -h -s $(top_builddir)/src/backend/utils/probes.d -o $(top_builddir)/src/include/probes.h
+ endif
  	$(MAKE) -C port $@
  	$(MAKE) -C timezone $@
  	$(MAKE) -C backend $@
Index: src/backend/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/backend/Makefile,v
retrieving revision 1.127
diff -c -r1.127 Makefile
*** src/backend/Makefile	26 Feb 2008 14:42:27 -	1.127
--- src/backend/Makefile	27 Feb 2008 03:22:55 -
***
*** 20,28 
--- 20,30 
  
  include $(srcdir)/common.mk
  
+ ifeq ($(PORTNAME), solaris)
  ifeq ($(enable_dtrace), yes)
  LOCALOBJS += utils/probes.o
  endif
+ endif
  
  OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
  
***
*** 135,144 
  	cd $(dir $@)  rm -f $(notdir $@)  \
  	$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
  
! 
! utils/probes.o: utils/probes.d $(SUBDIROBJS)
! 	$(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@
! 
  
  ##
  
--- 137,146 
  	cd $(dir $@)  rm -f $(notdir $@)  \
  	$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
  
! ifeq ($(PORTNAME), solaris)
! utils/probes.o: $(SUBDIROBJS)
! 	$(DTRACE) $(DTRACEFLAGS) -G -s $(srcdir)/utils/probes.d -o $@ $(call expand_subsys,$^)
! endif
  
  ##
  
Index: src/backend/access/transam/xact.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.257
diff -c -r1.257 xact.c
*** src/backend/access/transam/xact.c	15 Jan 2008 18:56:59 -	1.257
--- src/backend/access/transam/xact.c	27 Feb 2008 03:22:56 -
***
*** 1479,1485 
  	Assert(MyProc-backendId == vxid.backendId);
  	MyProc-lxid = vxid.localTransactionId;
  
! 	PG_TRACE1(transaction__start, vxid.localTransactionId);
  
  	/*
  	 * set transaction_timestamp() (a/k/a now()).  We want this to be the same
--- 1479,1485 
  	Assert(MyProc-backendId == vxid.backendId);
  	MyProc-lxid = vxid.localTransactionId;
  
! 	POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
  
  	/*
  	 * set transaction_timestamp() (a/k/a now()).  We want this to be the same
***
*** 1604,1610 
  	 */
  	latestXid = RecordTransactionCommit();
  
! 	PG_TRACE1(transaction__commit, MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
--- 1604,1610 
  	 */
  	latestXid = RecordTransactionCommit();
  
! 	POSTGRESQL_TRANSACTION_COMMIT(MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
***
*** 1990,1996 
  	 */
  	latestXid = RecordTransactionAbort(false);
  
! 	PG_TRACE1(transaction__abort, MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
--- 1990,1996 
  	 */
  	latestXid = RecordTransactionAbort(false);
  
! 	POSTGRESQL_TRANSACTION_ABORT(MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
Index: src/backend/storage/lmgr/lock.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v
retrieving revision 1.181
diff -c -r1.181 lock.c
*** src/backend/storage/lmgr/lock.c	2 Feb 2008 22:26:17 -	1.181
--- 

Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Alvaro Herrera
Robert Lor wrote:

 3) Note on src/backend/Makefile
   The current rule below does not work. After expansion, utils/probes.d  
 needs
   to come right after -s, but currently it shows up at the end after all 
 the .o files.

   utils/probes.o: utils/probes.d $(SUBDIROBJS)
   $(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@

Perhaps you need a $ there:

   $(DTRACE) $(DTRACEFLAGS) -G -s $ $(call expand_subsys,$^) -o $@

However I think you would also need to $(filter-out) the $ from $^.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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


Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Robert Lor

Alvaro Herrera wrote:

Perhaps you need a $ there:

   $(DTRACE) $(DTRACEFLAGS) -G -s $ $(call expand_subsys,$^) -o $@

However I think you would also need to $(filter-out) the $ from $^.

  

Your suggestion with $(filter-out ...) works. Thanks!

Attached is the updated patch.

Regards,
-Robert

? src/include/probes_null.h
Index: src/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/Makefile,v
retrieving revision 1.42
diff -c -r1.42 Makefile
*** src/Makefile	21 Aug 2007 01:11:12 -	1.42
--- src/Makefile	27 Feb 2008 17:09:41 -
***
*** 14,19 
--- 14,22 
  
  
  all install installdirs uninstall distprep:
+ ifeq ($(enable_dtrace), yes)
+ 	$(DTRACE) -h -s $(top_builddir)/src/backend/utils/probes.d -o $(top_builddir)/src/include/probes.h
+ endif
  	$(MAKE) -C port $@
  	$(MAKE) -C timezone $@
  	$(MAKE) -C backend $@
Index: src/backend/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/backend/Makefile,v
retrieving revision 1.127
diff -c -r1.127 Makefile
*** src/backend/Makefile	26 Feb 2008 14:42:27 -	1.127
--- src/backend/Makefile	27 Feb 2008 17:09:41 -
***
*** 20,28 
--- 20,30 
  
  include $(srcdir)/common.mk
  
+ ifeq ($(PORTNAME), solaris)
  ifeq ($(enable_dtrace), yes)
  LOCALOBJS += utils/probes.o
  endif
+ endif
  
  OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
  
***
*** 135,144 
  	cd $(dir $@)  rm -f $(notdir $@)  \
  	$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
  
! 
  utils/probes.o: utils/probes.d $(SUBDIROBJS)
! 	$(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@
! 
  
  ##
  
--- 137,146 
  	cd $(dir $@)  rm -f $(notdir $@)  \
  	$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
  
! ifeq ($(PORTNAME), solaris)
  utils/probes.o: utils/probes.d $(SUBDIROBJS)
! 	$(DTRACE) $(DTRACEFLAGS) -G -s $ $(filter-out $, $(call expand_subsys,$^)) -o $@
! endif
  
  ##
  
Index: src/backend/access/transam/xact.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.257
diff -c -r1.257 xact.c
*** src/backend/access/transam/xact.c	15 Jan 2008 18:56:59 -	1.257
--- src/backend/access/transam/xact.c	27 Feb 2008 17:09:41 -
***
*** 1479,1485 
  	Assert(MyProc-backendId == vxid.backendId);
  	MyProc-lxid = vxid.localTransactionId;
  
! 	PG_TRACE1(transaction__start, vxid.localTransactionId);
  
  	/*
  	 * set transaction_timestamp() (a/k/a now()).  We want this to be the same
--- 1479,1485 
  	Assert(MyProc-backendId == vxid.backendId);
  	MyProc-lxid = vxid.localTransactionId;
  
! 	POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
  
  	/*
  	 * set transaction_timestamp() (a/k/a now()).  We want this to be the same
***
*** 1604,1610 
  	 */
  	latestXid = RecordTransactionCommit();
  
! 	PG_TRACE1(transaction__commit, MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
--- 1604,1610 
  	 */
  	latestXid = RecordTransactionCommit();
  
! 	POSTGRESQL_TRANSACTION_COMMIT(MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
***
*** 1990,1996 
  	 */
  	latestXid = RecordTransactionAbort(false);
  
! 	PG_TRACE1(transaction__abort, MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
--- 1990,1996 
  	 */
  	latestXid = RecordTransactionAbort(false);
  
! 	POSTGRESQL_TRANSACTION_ABORT(MyProc-lxid);
  
  	/*
  	 * Let others know about no transaction in progress by me. Note that this
Index: src/backend/storage/lmgr/lock.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v
retrieving revision 1.181
diff -c -r1.181 lock.c
*** src/backend/storage/lmgr/lock.c	2 Feb 2008 22:26:17 -	1.181
--- src/backend/storage/lmgr/lock.c	27 Feb 2008 17:09:42 -
***
*** 787,797 
  		 * Sleep till someone wakes me up.
  		 */
  
! 		PG_TRACE2(lock__startwait, locktag-locktag_field2, lockmode);
  
  		WaitOnLock(locallock, owner);
  
! 		PG_TRACE2(lock__endwait, locktag-locktag_field2, lockmode);
  
  		/*
  		 * NOTE: do not do any material change of state between here and
--- 787,797 
  		 * Sleep till someone wakes me up.
  		 */
  
! 		POSTGRESQL_LOCK_STARTWAIT(locktag-locktag_field2, lockmode);
  
  		WaitOnLock(locallock, owner);
  
! 		POSTGRESQL_LOCK_ENDWAIT(locktag-locktag_field2, lockmode);
  
  		/*
  		 * NOTE: do not do any material change of state between here and
Index: src/backend/storage/lmgr/lwlock.c

Re: [PATCHES] SRF memory leaks

2008-02-27 Thread Neil Conway
On Tue, 2008-02-26 at 12:09 -0800, Neil Conway wrote:
 I'd like to apply this change to back branches reasonably soon, so if
 you have a better way to do the FreeTupleDesc() hack, let me know.

Barring any objections, I'll apply this to HEAD and back branches
tonight or tomorrow.

-Neil



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


Re: [PATCHES] SRF memory leaks

2008-02-27 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 On Tue, 2008-02-26 at 00:17 -0800, Neil Conway wrote:
 You didn't comment on my proposed solution (FreeTupleDesc() iff refcount
 == -1).

I still find that entirely unsafe, particularly for something you
propose to back-patch into stable branches.  Negative refcount does
not prove that the SRF itself hasn't still got a pointer to the tupdesc.

Can't we fix it so that the tupdesc is allocated in the new special
context (at least in the primary code paths), and then no explicit
free is needed?

regards, tom lane

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

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


Re: [PATCHES] SRF memory leaks

2008-02-27 Thread Neil Conway
On Wed, 2008-02-27 at 15:07 -0500, Tom Lane wrote:
 Negative refcount does not prove that the SRF itself hasn't
 still got a pointer to the tupdesc.

That sounds quite bizarre. The SRF has already finished execution at
this point, so keeping a pointer to the tupledesc around would only make
sense if you wanted to use that tupledesc on a *subsequent* invocation
of the SRF. The SRF would need to store the pointer in a static
variable, too, and it wouldn't have an easy way to distinguish between
repeated calls to the SRF within the same query and in different queries
(since in the latter case the TupleDesc will be long gone anyway). I
can't see why anyone would want to do this.

 Can't we fix it so that the tupdesc is allocated in the new special
 context (at least in the primary code paths), and then no explicit
 free is needed?

As I said earlier, the tupdesc is explicitly allocated in the per-query
context by the SRFs themselves. If by primary code paths, you mean
SRFs in the main source tree, then sure, we can make arbitrary changes
to those. That won't help out-of-tree SRFs though.

-Neil



---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate


Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Peter Eisentraut
Robert Lor wrote:
 3) Note on src/backend/Makefile
    The current rule below does not work. After expansion, utils/probes.d
 needs
    to come right after -s, but currently it shows up at the end after
 all the .o files.

I fixed that part.  Note again that a buildfarm animal testing the dtrace 
support could be helpful. :)

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

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


Re: [HACKERS] [PATCHES] 2WRS [WIP]

2008-02-27 Thread manolo.espa

Referring to tuplesort.c   andtuplestore.c

BACKGROUND: Starting from dumptuples()  [ tuplesort.c ] write functions move 
the tuple from a buffer to another in order to finally write it in a logical 
tape. Is there a way (even the most inefficient way) to use current 
read/write functions provided by PostgreSQL in order to retrieve the first 
tuple of a certain run while performing External Sorting?


NOTE: I need the first tuple in order to manipulate the whole corresponding 
run, tuple by tuple since they are written sequentially in a run.


Thanks for your attention.
Regards, Manolo.


--
From: [EMAIL PROTECTED]
Sent: Tuesday, February 26, 2008 4:10 PM
To: Jaime Casanova [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Decibel! [EMAIL PROTECTED]; David Fetter [EMAIL PROTECTED]; 
pgsql-patches@postgresql.org; [EMAIL PROTECTED]

Subject: Re: [HACKERS] [PATCHES] 2WRS [WIP]


For the joy of all of you: that's the correct WIP patch.
At the moment it only tries to create runs uding two heaps. Hope you can
help me with writing those runs on tapes.

I'd be very pleased to give you more details.

Thenks for your time.
Regards, Manolo.


--
From: Jaime Casanova [EMAIL PROTECTED]
Sent: Friday, February 22, 2008 5:30 AM
To: [EMAIL PROTECTED]
Cc: Decibel! [EMAIL PROTECTED]; Manolo _ [EMAIL PROTECTED];
David Fetter [EMAIL PROTECTED]; pgsql-patches@postgresql.org;
[EMAIL PROTECTED]
Subject: Re: [HACKERS] [PATCHES] 2WRS [WIP]


On Thu, Feb 21, 2008 at 6:44 AM,  [EMAIL PROTECTED] wrote:

Hi.

That's the last release and refers to 8.3.0 and not to 8.2.5 as before.
Hope
you can tell me if I created it correctly please.



no, it doesn't...


! /* GUC variables */
  #ifdef TRACE_SORT
  bool trace_sort = false;
  #endif
- #ifdef DEBUG_BOUNDED_SORT
- bool optimize_bounded_sort = true;
- #endif


it's seems you're removing something added in 8.3

--
regards,
Jaime Casanova

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning.
Richard Cook

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



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

  http://archives.postgresql.org


Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Peter Eisentraut
Robert Lor wrote:
 Please find the patch attached per this thread
 http://archives.postgresql.org/pgsql-hackers/2008-02/msg00912.php

Why do we have two dtrace calls in the makefiles now?  I understand you added 
the new mechanism to support Mac OS X, but doesn't Solaris support that 
mechanism as well, so the old one could be dropped?

Btw., probes_null.h is missing in your patch.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

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

   http://archives.postgresql.org


Re: [PATCHES] SRF memory leaks

2008-02-27 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 On Wed, 2008-02-27 at 15:07 -0500, Tom Lane wrote:
 Negative refcount does not prove that the SRF itself hasn't
 still got a pointer to the tupdesc.

 That sounds quite bizarre. The SRF has already finished execution at
 this point, so keeping a pointer to the tupledesc around would only make
 sense if you wanted to use that tupledesc on a *subsequent* invocation
 of the SRF.

Hmm ... actually I was worried about it being embedded in the returned
tuplestore, but I see tuplestore doesn't currently use a tupdesc at all,
so maybe it isn't that big a problem.

regards, tom lane

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

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


Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Peter Eisentraut
Robert Lor wrote:
 2) Need help figuring out how to copy src/backend/util/probes.d from src
 tree to
  bld tree at build time. It works fine if compilation is done in the src
 tree.

I have reworked your build rules so they look more like the idioms that we 
already use for other similar cases.  This should fix the troubles you 
describe and others.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/
Index: src/backend/Makefile
===
RCS file: /cvsroot/pgsql/src/backend/Makefile,v
retrieving revision 1.127
diff -u -3 -p -r1.127 Makefile
--- src/backend/Makefile	26 Feb 2008 14:42:27 -	1.127
+++ src/backend/Makefile	27 Feb 2008 21:05:40 -
@@ -20,9 +20,11 @@ SUBDIRS = access bootstrap catalog parse
 
 include $(srcdir)/common.mk
 
+ifeq ($(PORTNAME), solaris)
 ifeq ($(enable_dtrace), yes)
 LOCALOBJS += utils/probes.o
 endif
+endif
 
 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
 
@@ -122,6 +124,9 @@ $(srcdir)/parser/parse.h: parser/gram.y
 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
 	$(MAKE) -C utils fmgroids.h
 
+utils/probes.h: utils/probes.d
+	$(MAKE) -C utils probes.h
+
 # Make symlinks for these headers in the include directory. That way
 # we can cut down on the -I options. Also, a symlink is automatically
 # up to date when we update the base file.
@@ -135,9 +140,15 @@ $(top_builddir)/src/include/utils/fmgroi
 	cd $(dir $@)  rm -f $(notdir $@)  \
 	$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
 
+$(top_builddir)/src/include/utils/probes.h: utils/probes.h
+	cd $(dir $@)  rm -f $(notdir $@)  \
+	$(LN_S) ../../../$(subdir)/utils/probes.h .
 
+
+ifeq ($(PORTNAME), solaris)
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@
+endif
 
 
 ##
Index: src/backend/access/transam/xact.c
===
RCS file: /cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.257
diff -u -3 -p -r1.257 xact.c
--- src/backend/access/transam/xact.c	15 Jan 2008 18:56:59 -	1.257
+++ src/backend/access/transam/xact.c	27 Feb 2008 21:05:41 -
@@ -1479,7 +1479,7 @@ StartTransaction(void)
 	Assert(MyProc-backendId == vxid.backendId);
 	MyProc-lxid = vxid.localTransactionId;
 
-	PG_TRACE1(transaction__start, vxid.localTransactionId);
+	POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
 
 	/*
 	 * set transaction_timestamp() (a/k/a now()).  We want this to be the same
@@ -1604,7 +1604,7 @@ CommitTransaction(void)
 	 */
 	latestXid = RecordTransactionCommit();
 
-	PG_TRACE1(transaction__commit, MyProc-lxid);
+	POSTGRESQL_TRANSACTION_COMMIT(MyProc-lxid);
 
 	/*
 	 * Let others know about no transaction in progress by me. Note that this
@@ -1990,7 +1990,7 @@ AbortTransaction(void)
 	 */
 	latestXid = RecordTransactionAbort(false);
 
-	PG_TRACE1(transaction__abort, MyProc-lxid);
+	POSTGRESQL_TRANSACTION_ABORT(MyProc-lxid);
 
 	/*
 	 * Let others know about no transaction in progress by me. Note that this
Index: src/backend/storage/lmgr/lock.c
===
RCS file: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v
retrieving revision 1.181
diff -u -3 -p -r1.181 lock.c
--- src/backend/storage/lmgr/lock.c	2 Feb 2008 22:26:17 -	1.181
+++ src/backend/storage/lmgr/lock.c	27 Feb 2008 21:05:41 -
@@ -787,11 +787,11 @@ LockAcquire(const LOCKTAG *locktag,
 		 * Sleep till someone wakes me up.
 		 */
 
-		PG_TRACE2(lock__startwait, locktag-locktag_field2, lockmode);
+		POSTGRESQL_LOCK_STARTWAIT(locktag-locktag_field2, lockmode);
 
 		WaitOnLock(locallock, owner);
 
-		PG_TRACE2(lock__endwait, locktag-locktag_field2, lockmode);
+		POSTGRESQL_LOCK_ENDWAIT(locktag-locktag_field2, lockmode);
 
 		/*
 		 * NOTE: do not do any material change of state between here and
Index: src/backend/storage/lmgr/lwlock.c
===
RCS file: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v
retrieving revision 1.50
diff -u -3 -p -r1.50 lwlock.c
--- src/backend/storage/lmgr/lwlock.c	1 Jan 2008 19:45:52 -	1.50
+++ src/backend/storage/lmgr/lwlock.c	27 Feb 2008 21:05:41 -
@@ -447,7 +447,7 @@ LWLockAcquire(LWLockId lockid, LWLockMod
 		block_counts[lockid]++;
 #endif
 
-		PG_TRACE2(lwlock__startwait, lockid, mode);
+		POSTGRESQL_LWLOCK_STARTWAIT(lockid, mode);
 
 		for (;;)
 		{
@@ -458,7 +458,7 @@ LWLockAcquire(LWLockId lockid, LWLockMod
 			extraWaits++;
 		}
 
-		PG_TRACE2(lwlock__endwait, lockid, mode);
+		POSTGRESQL_LWLOCK_ENDWAIT(lockid, mode);
 
 		LOG_LWDEBUG(LWLockAcquire, lockid, awakened);
 
@@ -469,7 +469,7 @@ LWLockAcquire(LWLockId lockid, LWLockMod
 	/* We are done updating shared state of the lock itself. */
 	SpinLockRelease(lock-mutex);
 
-	PG_TRACE2(lwlock__acquire, 

Re: [PATCHES] DTrace probe patch for OS X Leopard

2008-02-27 Thread Robert Lor

Peter Eisentraut wrote:
I have reworked your build rules so they look more like the idioms that we 
already use for other similar cases.  This should fix the troubles you 
describe and others.
  

There are a couple of problems with your updated patch:

1) utils/probes.h needs to be generated before any file is compiled 
since it's used in c.h and a lot of files include c.h. That's why in my 
previous patch, I had a rule to call $(DTRACE) -h -s $ -o $@ in 
src/Makefile, and I don't think it will work putting it in 
src/backend/utils/Makefile. If utils/probes.h doesn't exist, you get 
compilation errors right of the bat.


...
gmake -C port all
gmake[2]: Entering directory `/export/home/pgs/src/pgsql/src/port'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline 
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing 
-I../../src/port -DFRONTEND -I../../src/include   -c -o isinf.o isinf.c 
-MMD -MP -MF .deps/isinf.Po

In file included from isinf.c:15:
../../src/include/c.h:60:26: utils/probes.h: No such file or directory
gmake[2]: *** [isinf.o] Error 1
gmake[2]: Leaving directory `/export/home/pgs/src/pgsql/src/port'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/export/home/pgs/src/pgsql/src'
gmake: *** [all] Error 2

It there a simple way to link to src/backend/utils/probes.d from a build 
tree and put the generated probes.h in src/include/utils instead of 
generate probes.h in src/backend/utils and link to in from 
src/include/utils?


2) c.h needs to have an ifdef like below. probes_null.h is attached, and 
this file is static and is used in the case Dtrace is not enabled.


#ifdef ENABLE_DTRACE
#include utils/probes.h
#else
#include utils/probes_null.h
#endif


Regards,
-Robert
/* --
 *  probes_null.h
 *
 *  Definitions of probe macros used when DTrace is not enabled.
 *
 *  Copyright (c) 2006-2008, PostgreSQL Global Development Group
 *
 * --
 */

#ifndef _PROBES_NULL_H
#define _PROBES_NULL_H

#define POSTGRESQL_LOCK_ENDWAIT(arg0, arg1)
#define POSTGRESQL_LOCK_ENDWAIT_ENABLED()

#define POSTGRESQL_LOCK_STARTWAIT(arg0, arg1)
#define POSTGRESQL_LOCK_STARTWAIT_ENABLED()

#define POSTGRESQL_LWLOCK_ACQUIRE(arg0, arg1)
#define POSTGRESQL_LWLOCK_ACQUIRE_ENABLED()

#define POSTGRESQL_LWLOCK_CONDACQUIRE(arg0, arg1)
#define POSTGRESQL_LWLOCK_CONDACQUIRE_ENABLED()

#define POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(arg0, arg1)
#define POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL_ENABLED()

#define POSTGRESQL_LWLOCK_ENDWAIT(arg0, arg1)
#define POSTGRESQL_LWLOCK_ENDWAIT_ENABLED()

#define POSTGRESQL_LWLOCK_RELEASE(arg0)
#define POSTGRESQL_LWLOCK_RELEASE_ENABLED()

#define POSTGRESQL_LWLOCK_STARTWAIT(arg0, arg1)
#define POSTGRESQL_LWLOCK_STARTWAIT_ENABLED()

#define POSTGRESQL_TRANSACTION_ABORT(arg0)
#define POSTGRESQL_TRANSACTION_ABORT_ENABLED()

#define POSTGRESQL_TRANSACTION_COMMIT(arg0)
#define POSTGRESQL_TRANSACTION_COMMIT_ENABLED()

#define POSTGRESQL_TRANSACTION_START(arg0)
#define POSTGRESQL_TRANSACTION_START_ENABLED()

#endif  /* _PROBES_NULL_H */

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

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