[PATCHES] pg_typeof() (was: Mysterious Bus Error with get_fn_expr_argtype())

2008-09-03 Thread Brendan Jurd
Hi folks,

As discussed on -hackers [1], here is a patch to add a pg_typeof()
builtin function to core.

The function accepts one argument (type any) and returns the regtype
of that argument.  This can be helpful in various circumstances,
including troubleshooting cast/coercion behaviour in a query, or
constructing dynamic SQL statements.

It's declared in builtins.h and defined in utils/adt/misc.c.

The patch includes a small documentation update; I added pg_typeof()
to Table 9-47. System Catalog Information Functions, and a brief
descriptive paragraph underneath the table.

This didn't seem like it warranted any additional regression tests.

Added to the November commitfest.

Cheers,
BJ

 doc/src/sgml/func.sgml   |   15 +++
 src/backend/utils/adt/misc.c |9 +
 src/include/catalog/catversion.h |2 !!
 src/include/catalog/pg_proc.h|2 ++
 src/include/utils/builtins.h |1 +
 5 files changed, 27 insertions(+), 2 modifications(!)

[1] http://archives.postgresql.org/message-id/[EMAIL PROTECTED]


pg_typeof.diff
Description: Binary data

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


[PATCHES] libpq events patch

2008-09-03 Thread Andrew Chernow

This is an updated version pf the libpqevents patch.  See

http://archives.postgresql.org/pgsql-hackers/2008-09/msg00153.php

for details.  The only change I didn't make yet is the event 'name'.  I 
have put it in and taken it out twice now, so a firm 'put it in there' 
would be appreciated.


Go here for libpqtypes using events.  pgfoundry is still using the older 
object hooks version.


http://libpqtypes.esilo.com/libpqtypes-events.tar.gz

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/
Index: src/interfaces/libpq/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/Makefile,v
retrieving revision 1.166
diff -C6 -r1.166 Makefile
*** src/interfaces/libpq/Makefile   16 Apr 2008 14:19:56 -  1.166
--- src/interfaces/libpq/Makefile   3 Sep 2008 16:06:49 -
***
*** 29,41 
  # the object files from libpgport, this would not be true on all
  # platforms.
  LIBS := $(LIBS:-lpgport=)
  
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
!   md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o 
strlcpy.o win32error.o, $(LIBOBJS))
  
  ifeq ($(PORTNAME), cygwin)
  override shlib = cyg$(NAME)$(DLSUFFIX)
  endif
  
--- 29,41 
  # the object files from libpgport, this would not be true on all
  # platforms.
  LIBS := $(LIBS:-lpgport=)
  
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
!   md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o 
libpq-events.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o 
strlcpy.o win32error.o, $(LIBOBJS))
  
  ifeq ($(PORTNAME), cygwin)
  override shlib = cyg$(NAME)$(DLSUFFIX)
  endif
  
***
*** 103,114 
--- 103,115 
  
  $(top_builddir)/src/port/pg_config_paths.h:
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
  
  install: all installdirs install-lib
$(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
+   $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pqexpbuffer.h 
'$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pg_service.conf.sample 
'$(DESTDIR)$(datadir)/pg_service.conf.sample'
  
  installdirs: installdirs-lib
$(mkinstalldirs) '$(DESTDIR)$(includedir)' 
'$(DESTDIR)$(includedir_internal)'
Index: src/interfaces/libpq/exports.txt
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/exports.txt,v
retrieving revision 1.19
diff -C6 -r1.19 exports.txt
*** src/interfaces/libpq/exports.txt19 Mar 2008 00:39:33 -  1.19
--- src/interfaces/libpq/exports.txt3 Sep 2008 16:06:49 -
***
*** 138,143 
--- 138,154 
  PQsendDescribePortal  136
  lo_truncate   137
  PQconnectionUsedPassword  138
  pg_valid_server_encoding_id 139
  PQconnectionNeedsPassword 140
  lo_import_with_oid  141
+ PQcopyResult  142
+ PQsetResultAttrs  143
+ PQsetvalue144
+ PQresultAlloc 145
+ PQregisterEventProc   146
+ PQinstanceData147
+ PQsetInstanceData 148
+ PQresultInstanceData  149
+ PQresultSetInstanceData   150
+ PQpassThroughData 151
+ PQresultPassThroughData   152
Index: src/interfaces/libpq/fe-connect.c
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.359
diff -C6 -r1.359 fe-connect.c
*** src/interfaces/libpq/fe-connect.c   29 May 2008 22:02:44 -  1.359
--- src/interfaces/libpq/fe-connect.c   3 Sep 2008 16:06:49 -
***
*** 1971,1982 
--- 1971,2000 
   * release data that is to be held for the life of the PGconn structure.
   * If a value ought to be cleared/freed during PQreset(), do it there not 
here.
   */
  static void
  freePGconn(PGconn *conn)
  {
+   int i;
+   PGEventConnDestroy evt;
+ 
+   /* Let the event procs cleanup their state data */
+   for(i=0; i  conn-nEvents; i++)
+   {
+   evt.conn = conn;
+   (void)conn-events[i].proc(PGEVT_CONNDESTROY, evt);
+   }
+ 
+   /* free the PGEvent array */
+   if(conn-events)
+   {
+   free(conn-events);
+   conn-events = NULL;
+   conn-nEvents = conn-eventArrSize = 0;
+   }
+ 
if (conn-pghost)
free(conn-pghost);
if (conn-pghostaddr)
free(conn-pghostaddr);
if 

Re: [PATCHES] libpq events patch

2008-09-03 Thread Alvaro Herrera
Andrew Chernow wrote:
 This is an updated version pf the libpqevents patch.  See

 http://archives.postgresql.org/pgsql-hackers/2008-09/msg00153.php

 for details.  The only change I didn't make yet is the event 'name'.  I  
 have put it in and taken it out twice now, so a firm 'put it in there'  
 would be appreciated.

You didn't merge the other changes I did to your patch.  Please use that
one as starting point, or merge them into your version.  They were
minor, sure, but I went some lengths to make them, which means the code
kinda has my signoff that way.  Please don't waste that work.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] libpq events patch

2008-09-03 Thread Andrew Chernow

Andrew Chernow wrote:

This is an updated version pf the libpqevents patch.  See

http://archives.postgresql.org/pgsql-hackers/2008-09/msg00153.php

for details.  The only change I didn't make yet is the event 'name'.  I 
have put it in and taken it out twice now, so a firm 'put it in there' 
would be appreciated.


Go here for libpqtypes using events.  pgfoundry is still using the older 
object hooks version.


http://libpqtypes.esilo.com/libpqtypes-events.tar.gz




Patch update again.  This one includes an optional event name for 
debugging purposes.  It also includes the changes made by Alvaro that I 
missed.


PQregisterEventProc now takes a name argumet.  If the name is NULL, the 
error message will identify the event procedure by its address ... 
addr:%p.  If its not NULL, error messages will indicate the provided name.


I updated the styling in libpq-events.c and a couple places in fe-exec.c 
that Alvaro missed.


--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/
Index: src/interfaces/libpq/Makefile
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/Makefile,v
retrieving revision 1.166
diff -C6 -r1.166 Makefile
*** src/interfaces/libpq/Makefile   16 Apr 2008 14:19:56 -  1.166
--- src/interfaces/libpq/Makefile   3 Sep 2008 21:55:06 -
***
*** 29,41 
  # the object files from libpgport, this would not be true on all
  # platforms.
  LIBS := $(LIBS:-lpgport=)
  
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
!   md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o 
strlcpy.o win32error.o, $(LIBOBJS))
  
  ifeq ($(PORTNAME), cygwin)
  override shlib = cyg$(NAME)$(DLSUFFIX)
  endif
  
--- 29,41 
  # the object files from libpgport, this would not be true on all
  # platforms.
  LIBS := $(LIBS:-lpgport=)
  
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
!   md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o 
libpq-events.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o 
strlcpy.o win32error.o, $(LIBOBJS))
  
  ifeq ($(PORTNAME), cygwin)
  override shlib = cyg$(NAME)$(DLSUFFIX)
  endif
  
***
*** 103,123 
  
  $(top_builddir)/src/port/pg_config_paths.h:
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
  
  install: all installdirs install-lib
$(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pqexpbuffer.h 
'$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pg_service.conf.sample 
'$(DESTDIR)$(datadir)/pg_service.conf.sample'
  
  installdirs: installdirs-lib
$(mkinstalldirs) '$(DESTDIR)$(includedir)' 
'$(DESTDIR)$(includedir_internal)'
  
  uninstall: uninstall-lib
!   rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' 
'$(DESTDIR)$(includedir_internal)/libpq-int.h' 
'$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' 
'$(DESTDIR)$(datadir)/pg_service.conf.sample'
  
  clean distclean: clean-lib
rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c 
noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c 
ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h libpq.rc
  # Might be left over from a Win32 client-only build
rm -f pg_config_paths.h
  
--- 103,124 
  
  $(top_builddir)/src/port/pg_config_paths.h:
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
  
  install: all installdirs install-lib
$(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
+   $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pqexpbuffer.h 
'$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pg_service.conf.sample 
'$(DESTDIR)$(datadir)/pg_service.conf.sample'
  
  installdirs: installdirs-lib
$(mkinstalldirs) '$(DESTDIR)$(includedir)' 
'$(DESTDIR)$(includedir_internal)'
  
  uninstall: uninstall-lib
!   rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' 
'$(DESTDIR)$(includedir)/libpq-events.h' 
'$(DESTDIR)$(includedir_internal)/libpq-int.h' 
'$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' 
'$(DESTDIR)$(datadir)/pg_service.conf.sample'
  
  clean distclean: clean-lib
rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c 
noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c 
ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h libpq.rc
  # Might be left over from a Win32 

[PATCHES] still alive?

2008-09-03 Thread Abhijit Menon-Sen
I thought -patches was supposed to die. What happened?

-- ams

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] hash index improving v3

2008-09-03 Thread Simon Riggs

On Mon, 2008-08-18 at 09:46 +0800, Xiao Meng wrote:
 There's minor change against the previous
 one( http://archives.postgresql.org/pgsql-hackers/2008-07/msg01183.php ).
 * merge branch master(Aug 16) into the patch 
 * clean code and make some comment
 Performance result is here
 http://wiki.postgresql.org/wiki/Gsoc08-hashindex
 
 It seems hash index is a little better on index creation and
 selection.
 But maybe  it's in the range of noise, I'm not sure. 
 I'd like to try it with a bigger dataset (e.g. table with 10GB) but
 there is not enough space in my computer.
 Anyone interest can make a test on a bigger data set.

You don't give the text of the query used to do these performance tests,
so I can't validate your test results.

Right now it seems strange that the index is larger than a btree, yet
the performance tests show that 3 times as much I/O was used accessing
the btree.

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Training, Services and Support


-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches