Search Postgresql Archives

Re: Custom C function - is palloc broken?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Craig Ringer wrote:
> Can you send me a complete, compileable example that illustrates the
> problem, along with instructions on how to reproduce it? If possible,
> send a compiled binary and any dependencies too. I'm curious to see if
> this is in fact shared library issues.

I'll send you a .zip file separately with the actual code, but here are the steps I took:

- Install Postgres 8.3.1
- Install MinGW 5.1.4
- Install the gettext snapshot from MinGW's downloads page under "snapshots"

Then, unzip the zip file I'll send you. Make sure MinGW's bin directory is in your windows PATH environment variable. In a command prompt, go to your unzipped directory and run mingw32-make. The makefile I've included will put the .dll in Postgres' lib/plugins directory (assuming you installed postgres in its default location - modify the makefile if that is not the case).

Once the .dll is ready, I created the function in Postgres using the CREATE FUNCTION command given in the documentation, modified slightly:

CREATE FUNCTION copytext(text) RETURNS text
     AS '$libdir/plugins/mylib.dll', 'copytext'
     LANGUAGE C STRICT;

Then I used the following SELECT statement:

SELECT copytext(colname) FROM tablename;

where "colname" is a text column in table "tablename". This statement crashes the database server.

I read somewhere on Postgres' website that the win32 binaries were built with MinGW - and in fact they must be, since MSVC++ does not have some of the unix headers needed to build Postgres.

Your theory could very well be true - especially if the issue is with a different version of gettext. MinGW's website's snapshot is from 2006 or something, so it wouldn't surprise me if Postgres uses a newer version.

A zip file is attached to a separate e-mail to you. Anyone else who would like a copy may have one, just let me know, but it's basically just the copytext example from the tutorials pasted into a .c file, and a makefile.

- Dan


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux