Trigger question

Поиск
Список
Период
Сортировка
Искать

Trigger question

От:
"Mitch Vincent" <mitch@venux.net>
Дата:
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; }




FAQ