1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-02 11:44:50 +03:00

Fix SPI example to reflect new-style calling convention for textout().

This commit is contained in:
Tom Lane 2001-03-23 01:51:08 +00:00
parent b1065f8fc2
commit 4e911c847c

View File

@ -2691,7 +2691,7 @@ are invisible to the query scan. For example, in query
INSERT INTO a SELECT * FROM a
tuples inserted are invisible for SELECT' scan. In effect, this
tuples inserted are invisible for SELECT's scan. In effect, this
duplicates the database table within itself (subject to unique index
rules, of course) without recursing.
</Para>
@ -2708,7 +2708,7 @@ of Q) or after Q is done.
<Para>
This example of SPI usage demonstrates the visibility rule.
There are more complex examples in in src/test/regress/regress.c and
There are more complex examples in src/test/regress/regress.c and
in contrib/spi.
</Para>
@ -2726,12 +2726,17 @@ int execq(text *sql, int cnt);
int
execq(text *sql, int cnt)
{
char *query;
int ret;
int proc = 0;
int proc;
/* Convert given TEXT object to a C string */
query = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(sql)));
SPI_connect();
ret = SPI_exec(textout(sql), cnt);
ret = SPI_exec(query, cnt);
proc = SPI_processed;
/*
@ -2743,11 +2748,11 @@ execq(text *sql, int cnt)
TupleDesc tupdesc = SPI_tuptable->tupdesc;
SPITupleTable *tuptable = SPI_tuptable;
char buf[8192];
int i;
int i,j;
for (ret = 0; ret < proc; ret++)
for (j = 0; j < proc; j++)
{
HeapTuple tuple = tuptable->vals[ret];
HeapTuple tuple = tuptable->vals[j];
for (i = 1, buf[0] = 0; i <= tupdesc->natts; i++)
sprintf(buf + strlen (buf), " %s%s",
@ -2759,6 +2764,8 @@ execq(text *sql, int cnt)
SPI_finish();
pfree(query);
return (proc);
}
</ProgramListing>