473,788 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_F UNCTION_ARGS);

PG_FUNCTION_INF O_V1(updatetrig );

Datum updatetrig(PG_F UNCTION_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*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
1 1460
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 YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #2

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

Similar topics

0
1609
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 backends. Whenever an entry is processed, its related fields are updated. The approaches I am considering for load-balancing are:
5
2194
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 connection so as to be able to run a locally linked version of the database outside of the production environment. No data will be modified; it will be read-only. I am struggling with docmd.transferdatabase and trying to empty the laptop-local...
2
3478
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 TableDef Dim Tdfs As TableDefs Dim Pathname As String Set dbs = CurrentDb Set Tdfs = dbs.TableDefs
7
6811
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 function in the Open Event of the MainMenu (which gets displayed at Startup). That seems to be too late, because I get an error that says that it can't find the tables (I moved the backend file to a different folder, for testing of this function). ...
5
6848
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 function in the Open Event of the MainMenu (which gets displayed at Startup). That seems to be too late, because I get an error that says that it can't find the tables (I moved the backend file to a different folder, for testing of this function). ...
12
2316
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 database backend as a single user. Therefore, wouldn't switching our Access (actually Jet 4.0 OLEDB) database backend on our ASP.NET/ADO.NET website to an MSDE backend be an advantageous change to make while NOT limiting the number of simultaneous web...
7
5271
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 determine why this is happening? I couldn't figure out how to run EXPLAIN ANALYZE from within the function. The queries aren't very complicated. Here is an example query and plan. About 240K rows in x_rbl_ips, 7.5M rows in filter_ips. explain...
4
10253
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: CREATE FUNCTION vacuum_values() RETURNS void AS $$ DECLARE r RECORD; BEGIN FOR r IN SELECT value_id FROM values NATURAL LEFT JOIN other_tab WHERE other_tab.value_id IS NULL FOR UPDATE OF values LOOP
6
1930
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 have tested the very same backend on another server with a sort path location at it works fine, but at the location above it is extremely
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.