Trigger question

From: "Mitch Vincent" <mitch(at)venux(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Trigger question
Date: 2000-06-27 19:54:11
Message-ID: 01e901bfe071$788e9640$0300000a@doot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is a bit off topic but email to the author of the trigger bounced..

In the fti.c (full text index) trigger I see..

sprintf(query, "INSERT INTO %s (string, id) VALUES ($1, $2)", indexname);

below.. I need to add something else here.. Basically I'm eliminating the
need for the text table, I'm going to integrate the fti indexed table into
an existing one I have but I need to insert naother ID into the resumes_fti
(my indexed fti table)..

The above makes the query string, as I can see but what in the world is the
$1 $2 and where did they come from? Since it looks like that's how the
values of string and id are put into the query, I need to know so I can add
one more in there..

Below is the whole function I'm referring to in fti.c

Thanks!!!

if (isinsert)
{
char *substring,
*column;
void *pplan;
Oid *argtypes;
Datum values[2];
int colnum;
struct varlena *data;
EPlan *plan;

sprintf(query, "I%s$%s", args[0], args[1]);
plan = find_plan(query, &InsertPlans, &nInsertPlans);

/* no plan yet, so allocate mem for argtypes */
if (plan->nplans <= 0)
{
argtypes = (Oid *) palloc(2 * sizeof(Oid));

argtypes[0] = VARCHAROID; /* create table t_name (string
* varchar, */
argtypes[1] = OIDOID; /* id oid); */

/* prepare plan to gain speed */
sprintf(query, "INSERT INTO %s (string, id) VALUES ($1, $2)",
indexname);
pplan = SPI_prepare(query, 2, argtypes);
if (!pplan)
elog(ERROR, "Full Text Indexing: SPI_prepare returned NULL "
"in insert");

pplan = SPI_saveplan(pplan);
if (pplan == NULL)
elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL"
" in insert");

plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan;
plan->nplans = 1;
}

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2000-06-27 20:10:00 Re: Proposal: More flexible backup/restore via pg_dump
Previous Message Bruce Momjian 2000-06-27 19:52:40 Re: Big 7.1 open items