NetBSD Problem Report #48567

From www@NetBSD.org  Mon Feb  3 03:40:42 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C14A5A645E
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  3 Feb 2014 03:40:42 +0000 (UTC)
Message-Id: <20140203034041.36CABA64B0@mollari.NetBSD.org>
Date: Mon,  3 Feb 2014 03:40:41 +0000 (UTC)
From: rhansen@bbn.com
Reply-To: rhansen@bbn.com
To: gnats-bugs@NetBSD.org
Subject: databases/py-postgresql fails with PostgreSQL < 9.0
X-Send-Pr-Version: www-1.0

>Number:         48567
>Category:       pkg
>Synopsis:       databases/py-postgresql fails with PostgreSQL < 9.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    darcy
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 03 03:45:00 +0000 2014
>Closed-Date:    Wed Mar 26 16:45:26 +0000 2014
>Last-Modified:  Wed Mar 26 16:45:26 +0000 2014
>Originator:     Richard Hansen
>Release:        2013Q4
>Organization:
BBN
>Environment:
NetBSD foo 6.1 NetBSD 6.1 (GENERIC) ... i386
>Description:
PyGreSQL (databases/py-postgresql) fails with PostgreSQL older than
9.0, even though the PyGreSQL web site claims support for versions as
old as 8.3:

  Traceback (most recent call last):
    ...
    File "/usr/pkg/lib/python2.6/site-packages/pgdb.py", line 66, in <module>
      from _pg import *
  ImportError: /usr/pkg/lib/python2.6/site-packages/_pg.so: Undefined PLT symbol "PQescapeIdentifier" (symnum = 4)

The symbol 'PQescapeIdentifier' was introduced in PostgreSQL 9.0.
Upstream is aware of the issue[1] and has committed a fix[2], but has
not yet made a release containing the fix.

[1] http://thread.gmane.org/gmane.comp.python.db.pygresql/1175
[2] http://shell.vex.net/viewvc.cgi/pygresql/trunk/module/setup.py?r1=509&r2=517&pathrev=517

>How-To-Repeat:
cd /usr/pkgsrc/databases/py-postgresql &&
make install PGSQL_VERSION_DEFAULT=84 &&
python2.7 <<EOF
import pgdb
EOF
>Fix:
diff --git a/pkgsrc/databases/py-postgresql/Makefile b/pkgsrc/databases/py-postgresql/Makefile
index 2f51d64..9828fc5 100644
--- a/pkgsrc/databases/py-postgresql/Makefile
+++ b/pkgsrc/databases/py-postgresql/Makefile
@@ -2,6 +2,7 @@

 DISTNAME=		PyGreSQL-4.1.1
 PKGNAME=		${PYPKGPREFIX}-postgresql-4.1.1
+PKGREVISION=		1
 CATEGORIES=		databases python
 MASTER_SITES=		http://pygresql.org/files/
 EXTRACT_SUFX=		.tgz
diff --git a/pkgsrc/databases/py-postgresql/distinfo b/pkgsrc/databases/py-postgresql/distinfo
index 94369db..df2139a 100644
--- a/pkgsrc/databases/py-postgresql/distinfo
+++ b/pkgsrc/databases/py-postgresql/distinfo
@@ -3,3 +3,4 @@ $NetBSD: distinfo,v 1.16 2013/01/08 15:09:59 darcy Exp $
 SHA1 (PyGreSQL-4.1.1.tgz) = eafd5b9ae92102bec088c7f2fe3ce3b359eb60c4
 RMD160 (PyGreSQL-4.1.1.tgz) = 5cd30aceb7cb82acb2e3a36045be30b21112dd3f
 Size (PyGreSQL-4.1.1.tgz) = 100883 bytes
+SHA1 (patch-setup.py) = 7b81bbd56e35b6449173480595bce4e74b2de641
diff --git a/pkgsrc/databases/py-postgresql/patches/patch-setup.py b/pkgsrc/databases/py-postgresql/patches/patch-setup.py
new file mode 100644
index 0000000..b267eaf
--- /dev/null
+++ b/pkgsrc/databases/py-postgresql/patches/patch-setup.py
@@ -0,0 +1,50 @@
+$NetBSD$
+
+  * Fix when building against PostgreSQL < 9.0:
+    http://shell.vex.net/viewvc.cgi/pygresql?view=revision&revision=517
+    http://thread.gmane.org/gmane.comp.python.db.pygresql/1175
+
+--- setup.py.orig	2013-01-08 14:47:33.000000000 +0000
++++ setup.py
+@@ -68,6 +68,17 @@ def pg_config(s):
+     return d
+ 
+ 
++def pg_version():
++    """Return the PostgreSQL version as a tuple of integers."""
++    parts = []
++    for part in pg_config('version').split()[-1].split('.'):
++        if part.isdigit():
++            part = int(part)
++        parts.append(part)
++    return tuple(parts or [8])
++
++
++pg_version = pg_version()
+ py_modules = ['pg', 'pgdb']
+ libraries = ['pq']
+ # Make sure that the Python header files are searched before
+@@ -95,7 +106,7 @@ class build_pg_ext(build_ext):
+             "enable string escaping functions")]
+ 
+     boolean_options = build_ext.boolean_options + [
+-        'direct-access', 'large-objects', 'default-vars']
++        'direct-access', 'large-objects', 'default-vars', 'escaping-funcs']
+ 
+     def get_compiler(self):
+         """Return the C compiler used for building the extension."""
+@@ -103,10 +114,10 @@ class build_pg_ext(build_ext):
+ 
+     def initialize_options(self):
+         build_ext.initialize_options(self)
+-        self.direct_access = 1
+-        self.large_objects = 1
+-        self.default_vars = 1
+-        self.escaping_funcs = 1
++        self.direct_access = True
++        self.large_objects = True
++        self.default_vars = True
++        self.escaping_funcs = pg_version[0] >= 9
+ 
+     def finalize_options(self):
+         """Set final values for all build_pg options."""

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->darcy
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Mon, 03 Feb 2014 16:32:47 +0000
Responsible-Changed-Why:
Over to maintainer


State-Changed-From-To: open->feedback
State-Changed-By: darcy@NetBSD.org
State-Changed-When: Wed, 05 Mar 2014 11:23:07 +0000
State-Changed-Why:
Patch applied.


State-Changed-From-To: feedback->closed
State-Changed-By: gdt@NetBSD.org
State-Changed-When: Wed, 26 Mar 2014 16:45:26 +0000
State-Changed-Why:
Fix was applied as requested.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.