By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,661 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,661 IT Pros & Developers. It's quick & easy.

undefined reference to 'pg_detoast_datum'

P: n/a
In PostgreSQL 7.2 (Redhat 7.3 version, so it is patched), I'm trying to
create a Version-1 C server extension. The Version-0 format works, the
Version-1 version fails with:
undefined reference to 'pg_detoast_datum'

According to docs at:
http://www.postgresql.org/docs/7.2/i...e/xfunc-c.html

....by using Version-1 the pg_detoast_datum is no longer needed. FYI, the
function being created takes and returns a text argument. Are the docs
there wrong, or is there a bug in the library build, that causes
Version-1 to require linking to a lib with pg_detoast_datum?

A google search shows very little concerning the pg_detoast_datum
undefined reference link error. It is looking more like the V1 has to be
skipped and I'll have to go back to V0 if I can't get this to work. [and
unless someone can magically make the default PostgreSQL version on RH
7.3 change to a newer version of PostgreSQL, then a newer version can't
be used]

D. Stimits
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
D. Stimits wrote:
A google search shows very little concerning the pg_detoast_datum
undefined reference link error. It is looking more like the V1 has to be
skipped and I'll have to go back to V0 if I can't get this to work.
You haven't shown us your function, so it's a bit difficult to help, but
in any case you do *not* want to use the V0 calling conventions -- they
are deprecated and subject to removal in the future. V1 certainly works
-- I've done many V1 C functions that accept text arguments. Take a look
at some of the contrib folder extensions if you need examples.
unless someone can magically make the default PostgreSQL version on RH
7.3 change to a newer version of PostgreSQL, then a newer version can't
be used]


Why not? I have Postgres 7.3.4 running on my RH 7.3 server. Here are RH
7.3 RPMs:
ftp://ftp8.us.postgresql.org/pub/pgs...MS/redhat-7.3/

Joe

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2

P: n/a
Joe Conway wrote:
D. Stimits wrote:
A google search shows very little concerning the pg_detoast_datum
undefined reference link error. It is looking more like the V1 has to
be skipped and I'll have to go back to V0 if I can't get this to work.

You haven't shown us your function, so it's a bit difficult to help, but
in any case you do *not* want to use the V0 calling conventions -- they
are deprecated and subject to removal in the future. V1 certainly works
-- I've done many V1 C functions that accept text arguments. Take a look
at some of the contrib folder extensions if you need examples.
unless someone can magically make the default PostgreSQL version on RH
7.3 change to a newer version of PostgreSQL, then a newer version
can't be used]

Why not? I have Postgres 7.3.4 running on my RH 7.3 server. Here are RH
7.3 RPMs:
ftp://ftp8.us.postgresql.org/pub/pgs...MS/redhat-7.3/


I'll consider this, but it greatly complicates things to require users
add the non-redhat version. I understand the benefits of doing so, but
convincing people to do this just to try out a package is not so easy.

Joe

Here is a simple echo function that is being used:

#include <pgsql/server/postgres.h>
#include <string.h>
#include <pgsql/server/fmgr.h>

PG_FUNCTION_INFO_V1(reverse_path);
Datum my_echo(PG_FUNCTION_ARGS)
{
text* arg = PG_GETARG_TEXT_P(0);
text* echo_arg = (text *)palloc(sizeof(arg));

memcpy(
(void *)(echo_arg),
(void *)(arg),
sizeof(arg)
);

PG_RETURN_TEXT_P(echo_arg);
}
Keep in mind that this isn't being run yet, it fails at link stage. As
another test, I have simplified the above just to test link time (not
intended to run, just as a test of link/compile):

#include <pgsql/server/postgres.h>
#include <pgsql/server/fmgr.h>

PG_FUNCTION_INFO_V1(reverse_path);
Datum my_echo(PG_FUNCTION_ARGS)
{
text* arg = PG_GETARG_TEXT_P(0);

PG_RETURN_TEXT_P(arg);
}
The first function complains at link time of missing link function
pg_detoast_datum, CurrentMemoryContext, and MemoryContextAlloc, while
the latter complains only of missing pg_detoast_datum.

In both cases, link libraries are:
-lkrb5 -lk5crypto -lcom_err -lpq -ldl

Now I am still scratching my head, wondering how it is that
pg_detoast_datum is a V0 function, and I can compile V0 libraries just
fine, but can't even compile a V1, which supposedly does not use
pg_detoast_data? The additional link failures when using palloc make me
feel there is some mysterious unnamed library that is missing when using
V1, aside from -lpq. When I go in to compile the src/test/regress/
directory of the source from the rpm used in Redhat 7.3, I see no signs
that anything else is required. Something simple must be missing under
the PostgreSQL 7.2 version. Is there a separate library that needs
linking under a V1 interface, in addition to those named above?

D. Stimits
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.