Gavin Sherry swm
Mon May 15 06:22:33 PDT 2006
Hi guys,

Tom modified the signature of typenameTypeId() so as to implement his
error offset handling when type lookups fail. The signature is now:

typenameTypeId(ParseState *pstate, const TypeName *typename)

For our purposes, we can just pass NULL for the first argument. In
mainline PostgreSQL this is fine because pstate is not dereferenced
without first testing if it is equal to NULL. Also, pstate is only used if
the type can not be found. We've got other problems if that's not possible
at the two call sites inside the slony code.

An attached patch updates the code to handle the API change.

Thanks,

Gavin
-------------- next part --------------
Index: config.h.in
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/config.h.in,v
retrieving revision 1.12.2.3
diff -c -p -r1.12.2.3 config.h.in
*** config.h.in	11 Nov 2005 17:23:54 -0000	1.12.2.3
--- config.h.in	15 May 2006 06:56:39 -0000
***************
*** 79,84 ****
--- 79,91 ----
  #define GetTopTransactionId() GetCurrentTransactionId()
  #endif
  
+ /* For PostgreSQL 8.2 and above typenameTypeId() has an extra arg */
+ #undef HAVE_NEW_TYPENAMETYPEID
+ #if HAVE_NEW_TYPENAMETYPEID
+ #define SL_GET_TYPEID(type) typenameTypeId(NULL, type)
+ #else
+ #define SL_GET_TYPEID(type) typenameTypeId(type)
+ #endif
  
  /* Set to 1 if we have POSIX signals */
  #undef HAVE_POSIX_SIGNALS
Index: config/acx_libpq.m4
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/config/acx_libpq.m4,v
retrieving revision 1.13.2.1
diff -c -p -r1.13.2.1 acx_libpq.m4
*** config/acx_libpq.m4	1 Nov 2005 20:33:04 -0000	1.13.2.1
--- config/acx_libpq.m4	15 May 2006 06:56:56 -0000
*************** for i in $PGCONFIG_POSSIBLE_LOCATIONS; d
*** 17,22 ****
--- 17,28 ----
      fi
  done
  
+ PG_VERSION=`$PG_CONFIG_LOCATION --version|cut -f2- -d' '|cut -f1 -d'd'|cut -f-2 -d'.'`
+ PG_MAJOR_VERSION=`echo $PG_VERSION |\
+           sed 's/\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+ PG_MINOR_VERSION=`echo $PG_VERSION |\
+           sed 's/\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+ 
  if test -n "$PG_CONFIG_LOCATION"; then
      AC_MSG_RESULT([$PG_CONFIG_LOCATION])
      PG_BINDIR=`$PG_CONFIG_LOCATION --bindir`/
*************** if test -n "$PG_CONFIG_LOCATION"; then
*** 25,37 ****
      PG_PKGLIBDIR=`$PG_CONFIG_LOCATION --pkglibdir`/
      PG_INCLUDESERVERDIR=`$PG_CONFIG_LOCATION --includedir-server`/
      PG_CONFIGURE=`$PG_CONFIG_LOCATION --configure`
-     PG_VERSION=`$PG_CONFIG_LOCATION --version|cut -f2- -d' '|cut -f1 -d'd'|cut -f-2 -d'.'`
  
      AC_MSG_CHECKING(for correct version of PostgreSQL)
-     PG_MAJOR_VERSION=`echo $PG_VERSION |\
-            sed 's/\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-     PG_MINOR_VERSION=`echo $PG_VERSION |\
-            sed 's/\([[0-9]]*\).\([[0-9]]*\)/\2/'`
      if test "$PG_MAJOR_VERSION" = "7"; then
  	if test $PG_MINOR_VERSION -gt 2; then
  	    AC_MSG_RESULT($PG_VERSION)
--- 31,38 ----
*************** if test $have_pqfreemem = yes; then
*** 243,248 ****
--- 244,254 ----
  	AC_DEFINE(HAVE_PQFREEMEM,1,[Postgresql PQfreemem()])
  fi
  
+ if test $PG_MAJOR_VERSION -gt "7" -a $PG_MINOR_VERSION -gt "1"; then
+ 	AC_DEFINE(HAVE_NEW_TYPENAMETYPEID,1,[typenameTypeId()])
+ fi
+ 
+ 
  AC_CHECK_DECLS([GetTopTransactionId],[],[],[
  #include "postgres.h"
  #include "access/xact.h"
Index: src/backend/slony1_funcs.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.33.2.4
diff -c -p -r1.33.2.4 slony1_funcs.c
*** src/backend/slony1_funcs.c	6 Jan 2006 17:07:46 -0000	1.33.2.4
--- src/backend/slony1_funcs.c	15 May 2006 06:56:58 -0000
*************** getClusterStatus(Name cluster_name, int 
*** 1297,1303 ****
  		xxid_typename->names =
  			lappend(lappend(NIL, makeString(NameStr(cs->clustername))),
  					makeString("xxid"));
! 		xxid_typid = typenameTypeId(xxid_typename);
  
  		plan_types[0] = INT4OID;
  
--- 1297,1303 ----
  		xxid_typename->names =
  			lappend(lappend(NIL, makeString(NameStr(cs->clustername))),
  					makeString("xxid"));
! 		xxid_typid = SL_GET_TYPEID(xxid_typename);
  
  		plan_types[0] = INT4OID;
  
*************** getClusterStatus(Name cluster_name, int 
*** 1377,1383 ****
  		xxid_typename->names =
  			lappend(lappend(NIL, makeString(NameStr(cs->clustername))),
  					makeString("xxid"));
! 		xxid_typid = typenameTypeId(xxid_typename);
  
  		/*
  		 * Create the saved plan's
--- 1377,1383 ----
  		xxid_typename->names =
  			lappend(lappend(NIL, makeString(NameStr(cs->clustername))),
  					makeString("xxid"));
! 		xxid_typid = SL_GET_TYPEID(xxid_typename);
  
  		/*
  		 * Create the saved plan's



More information about the Slony1-general mailing list