Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Fix for bug in plpython bool type conversion

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Guido Goldstein <pgpatches(at)a-nugget(dot)org>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Fix for bug in plpython bool type conversion
Date: 2007-01-25 14:54:18
Message-ID: 200701251454.l0PEsIW06569@momjian.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
I have had to reverse out this patch because Py_RETURN_TRUE is only
supported in Python versions >= 2.3, and we support older versions.  I
did add a comment:

*      We would like to use Py_RETURN_TRUE and Py_RETURN_FALSE here for
*      generating SQL from trigger functions, but those are only
*      supported in Python >= 2.3, and we support older
*      versions.  http://docs.python.org/api/boolObjects.html


---------------------------------------------------------------------------

bruce wrote:
> 
> Your patch has been added to the PostgreSQL unapplied patches list at:
> 
> 	http://momjian.postgresql.org/cgi-bin/pgpatches
> 
> It will be applied as soon as one of the PostgreSQL committers reviews
> and approves it.
> 
> ---------------------------------------------------------------------------
> 
> 
> Guido Goldstein wrote:
> > Hi!
> > 
> > The attached patch fixes a bug in plpython.
> > 
> > This bug was found while creating sql from trigger functions
> > written in plpython and later running the generated sql.
> > The problem was that boolean was was silently converted to
> > integer, which is ok for python but fails when the created
> > sql is used.
> > 
> > The patch uses the Py_RETURN_xxx macros shown at
> >  http://docs.python.org/api/boolObjects.html .
> > 
> > It would be nice if someone could test and comment
> > on the patch.
> > 
> > Cheers
> >   Guido
> 
> > --- postgresql-8.2.1.orig/src/pl/plpython/plpython.c	2006-11-21 22:51:05.000000000 +0100
> > +++ postgresql-8.2.1/src/pl/plpython/plpython.c	2007-01-17 18:06:58.185497734 +0100
> > @@ -1580,8 +1580,8 @@
> >  PLyBool_FromString(const char *src)
> >  {
> >  	if (src[0] == 't')
> > -		return PyInt_FromLong(1);
> > -	return PyInt_FromLong(0);
> > +		Py_RETURN_TRUE;
> > +	Py_RETURN_FALSE;
> >  }
> >  
> >  static PyObject *
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: don't forget to increase your free space map settings
> 
> -- 
>   Bruce Momjian   bruce(at)momjian(dot)us
>   EnterpriseDB    http://www.enterprisedb.com
> 
>   + If your life is a hard drive, Christ can be your backup. +

-- 
  Bruce Momjian   bruce(at)momjian(dot)us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

pgsql-hackers by date

Next:From: Simon RiggsDate: 2007-01-25 14:56:24
Subject: Re: WAL Record Header Size Reduction
Previous:From: Nikolay SamokhvalovDate: 2007-01-25 14:52:12
Subject: Proposal: allow installation of any contrib module simultaneously with Postgres itself

pgsql-patches by date

Next:From: Bruce MomjianDate: 2007-01-25 15:00:06
Subject: Re: pgsql: Fix for plpython functions; return
Previous:From: Magnus HaganderDate: 2007-01-25 14:40:16
Subject: Re: Getting rid of warnings

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group