Re: pgsql: Fix for plpython functions; return true/false for boolean,
От | Hannu Krosing |
---|---|
Тема | Re: pgsql: Fix for plpython functions; return true/false for boolean, |
Дата | |
Msg-id | 1170234480.3198.17.camel@localhost.localdomain обсуждение исходный текст |
Ответ на | Re: pgsql: Fix for plpython functions; return true/false for boolean, (Guido Goldstein <guido.goldstein@a-nugget.org>) |
Ответы |
Re: pgsql: Fix for plpython functions; return
true/false for boolean,
|
Список | pgsql-hackers |
Ühel kenal päeval, T, 2007-01-30 kell 14:52, kirjutas Guido Goldstein: > I've checked the patch with postgres 8.1.3 and 8.2.1 > with python 2.4 and 2.5 on intel 32 bit and amd 64 bit > systems; all systems running linux. > > *And* it's not a feature patch but a bug-fixing one! > Python is a language with strong typing, so silently > converting a datatype is a bug -- not a feature. Python is not that strongly typed. More it is a protocol based language, meaning that you should not relay on "type" of any variable, but rather see if it does what you want - so any type supporting iteration can be used if "for" and any thing not None, 0 or empty sequence/dict is considered to be TRUE True and False are actually 1 and 0 with different spelling ;) >>> True+2 3 >>> 1/False Traceback (most recent call last): File "<stdin>", line 1, in ? ZeroDivisionError: integer division or modulo by zero > Btw, you'll lose the type information of boolean columns in > trigger functions (NEW and OLD dicts, no explicit parameters), > which does cause problems. > > > That said, we certainly try to support a few more versions of Python > [...] > > If you want to support python 2.3 use the attached patch, which also > works for the newer python versions. > The Python 2.3 branch is the oldest _officially_ supported python version. Officially by who ? 2.3 was the first version to introduce bool as a subtype of int, in 2.2.3 True and False were introduced as two variables pointing to integers 1 and 0. So to make your patch ok on all python versions, just make it conditional on python version being 2.3 or bigger, and return int for pre-2.3. > Anyway, to circumvent the above mentiond point a) I herewith anncounce > that the included patch might break the buildfarm. :) > Cheers > Guido > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings -- ---------------- Hannu Krosing Database Architect Skype Technologies OÜ Akadeemia tee 21 F, Tallinn, 12618, Estonia Skype me: callto:hkrosing Get Skype for free: http://www.skype.com
В списке pgsql-hackers по дате отправления: