Hello,
I am writing my first trigger in C for PostgreSQL. It compiles Ok, and
added it to the database using CREATE TRIGGER. But when I try to fire
it, psql simply says 'The connection was lost". What I don't know is how
to get the row values (not the name fields) from tg_trigger.
The code is:
....
TriggerData *trigdata = (TriggerData *) fcinfo->context;
....
strcpy(query, "INSERT INTO visita_log VALUES ('");
strcat(query, trigdata->tg_trigger->tgargs[0]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[1]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[2]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[3]);
strcat(query, "',");
strcat(query, trigdata->tg_trigger->tgargs[4]);
strcat(query, ",'");
strcat(query, trigdata->tg_trigger->tgargs[5]);
strcat(query, "');");
SPI_exec(query, 0);
....
I don't know if tgargs[] return the row values or the field names.
Thanks.
Juan
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend 4 1489
On Fri, Jul 02, 2004 at 07:36:50AM -0300, Juan Jose Costello Levien wrote: I am writing my first trigger in C for PostgreSQL. It compiles Ok, and added it to the database using CREATE TRIGGER. But when I try to fire it, psql simply says 'The connection was lost".
Most likely the server process crashed. See the server log and the core
file for details to debug your function.
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
La web junta la gente porque no importa que clase de mutante sexual seas,
tienes millones de posibles parejas. Pon "buscar gente que tengan sexo con
ciervos incendiánse", y el computador dirá "especifiqu e el tipo de ciervo"
(Jason Alexander)
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Alvaro,
Sorry, but, where are the log file and core you mentioned? I tried
/var/log/postgresql but is in 0 file size.
TIA On Fri, Jul 02, 2004 at 07:36:50AM -0300, Juan Jose Costello Levien wrote: I am writing my first trigger in C for PostgreSQL. It compiles Ok, and added it to the database using CREATE TRIGGER. But when I try to fire it, psql simply says 'The connection was lost".
Most likely the server process crashed. See the server log and the core file for details to debug your function.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org
Juan Jose Costello Levien <jc*******@data full.com> writes: I don't know if tgargs[] return the row values or the field names.
Neither --- it's the (fixed) arguments you used in the CREATE TRIGGER
command. You'll need to do something involving extracting field values
from the tuple that is passed to the trigger, instead.
I'd suggest looking in the contrib/ modules for examples of triggers
written in C.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
On Fri, Jul 02, 2004 at 09:56:43AM -0300, Juan Jose Costello Levien wrote: Alvaro,
Sorry, but, where are the log file and core you mentioned? I tried /var/log/postgresql but is in 0 file size.
Your server may be misconfigured (most linux distros are). Make sure
your init script does not redirect postmaster's (or pg_ctl's)
stdout/stderr to /dev/null. Also make sure that if you are using
syslog, the syslog server is configured to save the messages somewhere
useful, by checking the facility Postgres uses (configurable) and where
does syslog save messages from this facility.
The core file, on the other hand, should be somewhere in
/var/lib/pgsql/data/base (if you haven't changed PGDATA), _unless_ the
server runs under a core 0-byte limit (under bash, ulimit -c will tell
you).
Hope this helps,
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Java is clearly an example of a money oriented programming" (A. Stepanov)
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul C-T |
last post by:
Hi,
Am I trying to be too clever here?
I am trying to write a PHP page to enable me to enter values into a form
then write those values to a text file.
I want to use the form & table that displays these fileds and values in
different ways so am creating one page and parsing variables to it.
The problem appears to be in trying to write the values to a text file. The
page displays the field names correctly but when I submit the form...
|
by: Sue Adams |
last post by:
I have a form on an asp page and am trying to write the code to place the values of all checkboxes that have been selected, into an array. The checkbox values will be used in a dynamic sql statement to retrieve information from an access database, to be displayed ont he page. Since I''ve never worked with arrays before I''ve been running tests and displaying values on the next page to help me figure out my code.
my array code reads like this:...
|
by: James Baker |
last post by:
I have a form that has a dropdown list that will cause a post to the same
page when it's changed. The problem I'm running into is that all of the
controls reset to their default values (obviously expected behavior).
What's the recommended/best way to persist these values through the post
process? I know I could set them to the request.form values of themselves,
so to speak...but I didn't know if there was a simpler/more efficient way.
...
|
by: Agoston Bejo |
last post by:
I want to enforce such a constraint on a column that would ensure that the
values be all unique, but this wouldn't apply to NULL values. (I.e. there
may be more than one NULL value in the column.)
How can I achieve this?
I suppose I would get the most-hated "table/view is changing,
trigger/function may not see it" error if I tried to write a trigger that
checks the uniqueness of non-null values upon insert/update.
|
by: Steve Hall |
last post by:
Folks,
My secnario involves two tables - ObservationRegister, and Person.
ObservationRegister contains most of the "useful" fields, including
the UserID of the person that raised the record, and the UserID of the
person to whom the record was assigned for action. I need to write a
query to return all values in the ObservationRegister record, but
instead of returning the UserIDs, I need to look up the actual name,
by looking up the name...
| |
by: cipher |
last post by:
I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };
However, the resulting wsdl omits the actual flag values:
- <s:simpleType name="Colors">
|
by: Hennie |
last post by:
I apologise if this is a stupid question, but I would appreciated any
help on this subject.
I want to create a view (VIEW_1 in example below) where I take numeric
values from a field in one table (DEPTH_FROM in TABLE_1) and find the
closest matching values from another field in another table (DEPTH_AT
in TABLE_2) - the higher matching value and the lower matching value.
TABLE_1
|
by: aleksandar.ristovski |
last post by:
Hello all,
I have been thinking about a possible extension to C/C++ syntax.
The current syntax allows declaring a function that returns a value:
int foo();
however, if I were to return more than one value, for example three
int-s, I would have to change my "logic" and pass the references to my
|
by: Gregor =?UTF-8?B?S292YcSN?= |
last post by:
Hi!
With VALUES you can do something like:
SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER)
which will give you:
LETTER NUMBER
------ ------
A 1
B 2
C 2
|
by: gigonomics |
last post by:
Hi all,
I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column where the values are integers). I can do this programmatically (using code and stored procedures), but it's not a neat solution and there are also performance issues.
Returning the best available X number of seats is very straightforward. But I...
|
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...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |