473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C Function causes backend to die in 7.4.3

Hiya,
I have written a C function for postgres. I developed and got this
function working on postgres 7.3.2, however the production system was
7.4.3.

On my initial dev setup it worked perfectly, however on the 7.4.3 it
caused the backend to terminate abnormaly!, I upgraded my dev system to
be the same version to ensure it wasn't just the production box, and
sure enough the function now also fails on my dev system!

I have commented out the entire function body looking for the cause of
the crash, and it seems that it is being cause by calling
PointerGetDatum() on the return. If I set return to NULL, then the
insert on the table doesn't cause a crash of the backend.

Any ideas? The C segment for my code on 7.4.3 which is crashing is as
follows:

extern Datum updatetrig(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(updatetrig);

Datum updatetrig(PG_FUNCTION_ARGS)
{
TriggerData *trigdata = (TriggerData *) fcinfo->context;
char *name;
char *data; // Temporary string
char *ptr; // Temp string for building

char *sql; // The SQL statement to add the update row
char *id; // The id of the row the update is for
char *idfield; // The field name of the id column
char *table; // The name of the table being modified
char *action; // The action undertaken by the update
char *update; // The update SQL itself

int noatts=0; // Number of attributes
int len=0; // Length of string needed
int a=0;

HeapTuple rettuple;

// Commented out code is here

return PointerGetDatum(rettuple);
}

thanks for any help

--
-----
Graeme Hinchliffe (BSc)
Core Internet Systems Designer
Zen Internet (http://www.zen.co.uk/)

Direct: 0845 058 9074
Main : 0845 058 9000
Fax : 0845 058 9005

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
1 1435
Graeme Hinchliffe <gr***************@zeninternet.co.uk> writes:
HeapTuple rettuple; // Commented out code is here return PointerGetDatum(rettuple);


It surprises you that returning an uninitialized pointer value will
crash the code that tries to use the pointer?

I strongly recommend using a compiler that will warn about uninitialized
values. If using gcc, you should use -O1 (at least).

I dunno what the original problem was, but maybe you just neglected to
recompile the function against 7.4 headers? We don't generally
guarantee binary compatibility of user-defined functions across major
releases.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Krishna Prasad | last post by:
Hello, I am in the process of designing the following kind of system -- A MySQL database holds hundreds of thousands of entries. All of these entries are periodically processed by a set of...
5
by: Derickson | last post by:
I am working with a production runtime Access 2000 db, split front-end and back-end. Running on a network, I need a nightly copy of the backend transferred to a laptop with a temporary network...
2
by: cmd | last post by:
I use a utility database and the following code to link from an original backend to a temporary backend, in order to replace the original with a newer version: Dim dbs As Database Dim tdf As...
7
by: SueB | last post by:
Hi. I want to execute a routine, at database startup time, to relink the backend tables. I have the code for the function, but I don't know where to invoke it. I tried putting a call to the...
5
by: SueB | last post by:
Hi. I want to execute a routine, at database startup time, to relink the backend tables. I have the code for the function, but I don't know where to invoke it. I tried putting a call to the...
12
by: Dan V. | last post by:
Since an ASP.NET/ADO.NET website is run on the server by a single "asp_net worker process", therefore doesn't that mean that even 50 simultaneous human users of the website would appear to the...
7
by: Jim Crate | last post by:
I have a couple queries in a PL/PGSQL function which execute very slowly (around one minute each) which execute in .5 second when not executed from within the function. Is there any way to...
4
by: Dawid Kuroczko | last post by:
Suppose I have vacuum_values() function, which removes all "no longer referenced" by parent column. Kind of function to be run from time to time to clean table from crud. It looks like this:...
6
by: bg_ie | last post by:
Hi, My company's backend is located at a location with a long address, something like - //our_servers/server_number_one/our_department/our_devision/ our_results/our_databases/backend.be I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.