pg_get_serial_sequence("unknown", "unknown") - revision 13336

142 views
Skip to first unread message

Federico Capoano

unread,
Jun 8, 2010, 5:47:15 PM6/8/10
to Django users
Hello to all,

I just upgraded to revision 13336, I tried then to add a post on my
blog but I got an error. I tried then to save any other object in the
admin but I get always the same error:

"DatabaseError: function pg_get_serial_sequence("unknown", "unknown")
does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts."

Traceback (most recent call last):

File "/usr/local/lib/python2.6/site-packages/django/core/handlers/
base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 239, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/views/decorators/
cache.py", line 69, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
sites.py", line 190, in inner
return view(request, *args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 21, in _wrapper
return decorator(bound_func)(*args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 17, in bound_func
return func(self, *args2, **kwargs2)

File "/usr/local/lib/python2.6/site-packages/django/db/
transaction.py", line 299, in _commit_on_success
res = func(*args, **kw)

File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 795, in add_view
self.save_model(request, new_object, form, change=False)

File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 597, in save_model
obj.save()

File "/usr/local/lib/python2.6/site-packages/django/db/models/
base.py", line 435, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)

File "/usr/local/lib/python2.6/site-packages/django/db/models/
base.py", line 528, in save_base
result = manager._insert(values, return_id=update_pk, using=using)

File "/usr/local/lib/python2.6/site-packages/django/db/models/
manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)

File "/usr/local/lib/python2.6/site-packages/django/db/models/
query.py", line 1479, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)

File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/
compiler.py", line 789, in execute_sql
self.query.model._meta.db_table, self.query.model._meta.pk.column)

File "/usr/local/lib/python2.6/site-packages/django/db/backends/
postgresql/operations.py", line 59, in last_insert_id
cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('%s','%s'))"
% (table_name, pk_name))

File "/usr/local/lib/python2.6/site-packages/django/db/backends/
postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)

Could anyone please help me and tell me what's this? It seems I'm the
only one getting this.

Russell Keith-Magee

unread,
Jun 8, 2010, 7:51:23 PM6/8/10
to django...@googlegroups.com
On Wed, Jun 9, 2010 at 5:47 AM, Federico Capoano
<nemesis...@libero.it> wrote:
> Hello to all,
>
> I just upgraded to revision 13336, I tried then to add a post on my
> blog but I got an error. I tried then to save any other object in the
> admin but I get always the same error:
>
> "DatabaseError: function pg_get_serial_sequence("unknown", "unknown")
> does not exist
> HINT:  No function matches the given name and argument types. You may
> need to add explicit type casts."

The call to pg_get_serial_sequence() was added recently, so for some reason,

The most obvious possible reason -- what version of Postgres are you
using? Very old (pre-8.0) Postgres doesn't have the
pg_set_serial_sequence() function defined.

Failing that, we'll need to do some more investigation; Can you
provide any other details of your setup that will help us narrow down
the problem?

Yours,
Russ Magee %-)

Federico Capoano

unread,
Jun 9, 2010, 6:27:25 AM6/9/10
to Django users
I have PostgreSQL version 7.4.27 on my server. The reason for which I
use this version is that is the latest version available for webmin
and my VPS use it.
What can I do?

I checked the release notes and I didn't notice anything about this
bit. Before upgrading to the last revision I had probably the trunk
equivalent to the just released 1.2

Thanks for your help.



On Jun 9, 1:51 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Jun 9, 2010 at 5:47 AM, Federico Capoano
>

Matt Hoskins

unread,
Jun 9, 2010, 7:20:05 AM6/9/10
to Django users
The calls to pg_get_serial_sequence were added in to fix #8901 and I
noted on that issue that the call wasn't available on PostgreSQL prior
to 8, that Django made no claims about which PostgreSQL version it
requires as a minimum, but that version 7 was rather old these days
with version 8 having been around for 5 years now.

Note that I think it is possible to create pg_get_serial_sequence for
PostgreSQL 7:
http://pgfoundry.org/tracker/index.php?func=detail&aid=1000463&group_id=1000151&atid=616
(perhaps you could test that Federico?)

As noted above, Version 8 was first released in 2005. Version 7.4 has
still had bug fixes by the PostgreSQL community to date however to
quote from the release notes "The PostgreSQL community will stop
releasing updates for the 7.4.X release series in July 2010. Users are
encouraged to update to a newer release branch soon. "

Russ - I guess the choice is either a note in the Django docs/release
notes about this issue and suggesting anyone on 7 adds in
pg_get_serial_sequence as per the above link (if that does indeed
work) or alternatively change the code touched by #8901 such that it
only adds the calls to pg_get_serial_sequence for version 8 onwards
and for version 7 it either reverts to guessing the sequence name as
it used to (with a caveat in the documentation that for long model or
field names there will be the errors that #8901 fixes) or
alternatively it calls the SQL listed in the above pgfoundry link to
fish out the sequence names itself (it could call that sql always
regardless of postgresql version but I guess there's a tiny risk that
in a later version of postgresql the catalog structure could change so
calling pg_get_serial_sequence is preferred when it's available).

Russell Keith-Magee

unread,
Jun 9, 2010, 7:21:16 AM6/9/10
to django...@googlegroups.com
On Wed, Jun 9, 2010 at 6:27 PM, Federico Capoano
<nemesis...@libero.it> wrote:
> I have PostgreSQL version 7.4.27 on my server. The reason for which I
> use this version is that is the latest version available for webmin
> and my VPS use  it.

In your defense, you didn't miss anything. We haven't documented a
minimum required version for Postgres. This is something we should
address.

> What can I do?

Well, The official 1.2.1 release doesn't include the call to
pg_get_serial_sequence(), so I would suggest checking out that
release. Unless you have a particularly compelling reason to do
otherwise, stable releases will always be a better option than
following trunk.

However, going forward, you *really* need to investigate your database
options. Postgres 7.4 will officially reach end-of-life in July [1];
this means that there won't be any further bug fixes or updates.

Django hasn't needed to make an official policy on Postgres
deprecations, but this changeset may force us to make a decision. If I
had to guess, I'd say imposing an 8.0 minimum, following the
PostgreSQL's own deprecation schedule; there isn't much benefit to be
had in supporting a backend that Postgres itself doesn't support.

[1] http://wiki.postgresql.org/wiki/PostgreSQL_Release_Support_Policy

Yours,
Russ Magee %-)

Matt Hoskins

unread,
Jun 9, 2010, 7:28:58 AM6/9/10
to Django users
... Replying to my own post on this bit... of course the older Django
1.1.x can still be used with the older PostgreSQL 7 without hitting
this issue regardless as I'm assuming the patch for #8901 isn't being
applied back to the 1.1 series :). Perhaps worth being explicit in the
Django documentation for 1.2 about which PostgreSQL version is
required as a minimum (both for the benefit of users and also for
anyone submitting patches to the PostgreSQL back-end so they know what
they have to work with!).

Federico Capoano

unread,
Jun 9, 2010, 9:53:04 AM6/9/10
to Django users
I see. I think I'd like to upgrade postgresql .. but I don't know what
would happen with webmin.
Maybe I'll go to ask to the webmin support.

Do you think upgrading from 7 to 8 is a difficult task on debian?

I also think it should be written in the documentation and release
notes.

Matt Hoskins

unread,
Jun 9, 2010, 12:24:04 PM6/9/10
to Django users
Hi Federico,

From the discussion on django-developers it looks like the patch will
be reverted soon so you may find in due course things will start
working again with SVN for the 1.2 branch (however with Django 1.3
support for 7 will likely be dropped). It doesn't sound like you
particularly need to be using the SVN version, since 1.2 has been
released, so I'd suggest just grabbing 1.2.1 and using that instead of
SVN for your blog as that doesn't have the patch which broke things
working with postgresql 7.

In terms of upgrading from 7 to 8 on debian it's the same as upgrading
from 7 to 8 on any system, you have to do it via data dumps and
imports rather than postgresql being able to upgrade the data files in-
place. There were some changes in the dump formats so to do a big jump
safely unfortunately what you really need is to run the pg_dump
command from version 8 talking to your version 7 server, and even then
with the later versions of 8 if you were using the tsearch2 full-text
index module there can be some problems as it's moved to being in the
core. Have a look at the section of the postgresql manual on migration
and if you want to know the gory details of any backwards-incompatible
changes also at the release notes for the 8.0 release and every minor
release up to the version you're intending to run (you can skip over
the point release release notes tho' as they don't tend to introduce
backwards-incompatibilities in point release changes). It will, in
part, depend on whether your version of webmin works with version 8.

I guess you'll have to make the jump to 8 eventually tho' even if you
hold off for now :)

Matt

Federico Capoano

unread,
Jun 10, 2010, 7:26:52 AM6/10/10
to Django users
Yea, you're right, thank you so much guys.

I downloaded django 1.2.1 stable and put that for the moment.

When I'll have time I will upgrade postgres.

Russell Keith-Magee

unread,
Jun 10, 2010, 8:01:17 AM6/10/10
to django...@googlegroups.com
On Thu, Jun 10, 2010 at 7:26 PM, Federico Capoano
<nemesis...@libero.it> wrote:
> Yea, you're right, thank you so much guys.
>
> I downloaded django 1.2.1 stable and put that for the moment.
>
> When I'll have time I will upgrade postgres.

FYI - I've just reverted r13328, so the 1.2 branch will support
Postgres 7.4 again. However, Django 1.3 will be formally dropping
support for Postgres 7.4, and imposing a Postgres 8.0 minimum version.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages