mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Allow to call utility funcs without SPI_connect.
This commit is contained in:
parent
7f97e05b09
commit
fd3ad7d765
@ -48,7 +48,7 @@ static void _SPI_fetch(FetchStmt * stmt);
|
|||||||
#endif
|
#endif
|
||||||
static int
|
static int
|
||||||
_SPI_execute_plan(_SPI_plan * plan,
|
_SPI_execute_plan(_SPI_plan * plan,
|
||||||
char **Values, char *Nulls, int tcount);
|
Datum *Values, char *Nulls, int tcount);
|
||||||
|
|
||||||
#define _SPI_CPLAN_CURCXT 0
|
#define _SPI_CPLAN_CURCXT 0
|
||||||
#define _SPI_CPLAN_PROCXT 1
|
#define _SPI_CPLAN_PROCXT 1
|
||||||
@ -199,7 +199,7 @@ SPI_exec(char *src, int tcount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SPI_execp(void *plan, char **Values, char *Nulls, int tcount)
|
SPI_execp(void *plan, Datum *Values, char *Nulls, int tcount)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
@ -282,10 +282,7 @@ int
|
|||||||
SPI_fnumber(TupleDesc tupdesc, char *fname)
|
SPI_fnumber(TupleDesc tupdesc, char *fname)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
return (SPI_ERROR_UNCONNECTED);
|
|
||||||
|
|
||||||
for (res = 0; res < tupdesc->natts; res++)
|
for (res = 0; res < tupdesc->natts; res++)
|
||||||
{
|
{
|
||||||
if (strcasecmp(tupdesc->attrs[res]->attname.data, fname) == 0)
|
if (strcasecmp(tupdesc->attrs[res]->attname.data, fname) == 0)
|
||||||
@ -300,12 +297,6 @@ SPI_fname(TupleDesc tupdesc, int fnumber)
|
|||||||
{
|
{
|
||||||
|
|
||||||
SPI_result = 0;
|
SPI_result = 0;
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tupdesc->natts < fnumber || fnumber <= 0)
|
if (tupdesc->natts < fnumber || fnumber <= 0)
|
||||||
{
|
{
|
||||||
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
||||||
@ -313,7 +304,6 @@ SPI_fname(TupleDesc tupdesc, int fnumber)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (nameout(&(tupdesc->attrs[fnumber - 1]->attname)));
|
return (nameout(&(tupdesc->attrs[fnumber - 1]->attname)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -324,12 +314,6 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
|
|||||||
Oid foutoid;
|
Oid foutoid;
|
||||||
|
|
||||||
SPI_result = 0;
|
SPI_result = 0;
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tuple->t_natts < fnumber || fnumber <= 0)
|
if (tuple->t_natts < fnumber || fnumber <= 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -353,12 +337,6 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull)
|
|||||||
|
|
||||||
*isnull = true;
|
*isnull = true;
|
||||||
SPI_result = 0;
|
SPI_result = 0;
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tuple->t_natts < fnumber || fnumber <= 0)
|
if (tuple->t_natts < fnumber || fnumber <= 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -373,12 +351,6 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
|
|||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
SPI_result = 0;
|
SPI_result = 0;
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tupdesc->natts < fnumber || fnumber <= 0)
|
if (tupdesc->natts < fnumber || fnumber <= 0)
|
||||||
{
|
{
|
||||||
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
||||||
@ -403,12 +375,6 @@ SPI_gettypeid(TupleDesc tupdesc, int fnumber)
|
|||||||
{
|
{
|
||||||
|
|
||||||
SPI_result = 0;
|
SPI_result = 0;
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (InvalidOid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tupdesc->natts < fnumber || fnumber <= 0)
|
if (tupdesc->natts < fnumber || fnumber <= 0)
|
||||||
{
|
{
|
||||||
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
SPI_result = SPI_ERROR_NOATTRIBUTE;
|
||||||
@ -421,14 +387,6 @@ SPI_gettypeid(TupleDesc tupdesc, int fnumber)
|
|||||||
char *
|
char *
|
||||||
SPI_getrelname(Relation rel)
|
SPI_getrelname(Relation rel)
|
||||||
{
|
{
|
||||||
|
|
||||||
SPI_result = 0;
|
|
||||||
if (_SPI_curid + 1 != _SPI_connected)
|
|
||||||
{
|
|
||||||
SPI_result = SPI_ERROR_UNCONNECTED;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (pstrdup(rel->rd_rel->relname.data));
|
return (pstrdup(rel->rd_rel->relname.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +539,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount)
|
_SPI_execute_plan(_SPI_plan * plan, Datum *Values, char *Nulls, int tcount)
|
||||||
{
|
{
|
||||||
QueryTreeList *queryTree_list = plan->qtlist;
|
QueryTreeList *queryTree_list = plan->qtlist;
|
||||||
List *planTree_list = plan->ptlist;
|
List *planTree_list = plan->ptlist;
|
||||||
@ -634,7 +592,7 @@ _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount)
|
|||||||
paramLI->kind = PARAM_NUM;
|
paramLI->kind = PARAM_NUM;
|
||||||
paramLI->id = k + 1;
|
paramLI->id = k + 1;
|
||||||
paramLI->isnull = (Nulls != NULL && Nulls[k] != 'n');
|
paramLI->isnull = (Nulls != NULL && Nulls[k] != 'n');
|
||||||
paramLI->value = (Datum) Values[k];
|
paramLI->value = Values[k];
|
||||||
}
|
}
|
||||||
paramLI->kind = PARAM_INVALID;
|
paramLI->kind = PARAM_INVALID;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user