index 755293456fff687183c969aeb9724db24af13c35..c1c82eb4dd8580d281bdfbcd9f033f5f6e6cba0b 100644 (file)
@@ -2377,9 +2377,7 @@ get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pk
/*
* Connect to SPI manager
*/
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "SPI connect failure - returned %d", ret);
+ SPI_connect();
initStringInfo(&buf);
index 18062eb1cffbd6ac3347f0053bb8db0ccc313d53..e1aef7cd2a3b897d34ec026d8a3bb3d78aaca6e1 100644 (file)
tupdesc = rel->rd_att;
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "check_primary_key: SPI_connect returned %d", ret);
+ SPI_connect();
/*
* We use SPI plan preparation feature, so allocate space to place key
tupdesc = rel->rd_att;
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "check_foreign_key: SPI_connect returned %d", ret);
+ SPI_connect();
/*
* We use SPI plan preparation feature, so allocate space to place key
index 7d1b5f514390c22a6ccce4a19e21f5aba84fad7f..2a25607a2adbe92806807aeb0780f399e3fc25ed 100644 (file)
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "crosstab: SPI_connect returned %d", ret);
+ SPI_connect();
/* Retrieve the desired rows */
ret = SPI_execute(sql, true, 0);
@@ -724,9 +722,7 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
HASH_ELEM | HASH_STRINGS | HASH_CONTEXT);
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "load_categories_hash: SPI_connect returned %d", ret);
+ SPI_connect();
/* Retrieve the category name rows */
ret = SPI_execute(cats_sql, true, 0);
tupstore = tuplestore_begin_heap(randomAccess, false, work_mem);
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "get_crosstab_tuplestore: SPI_connect returned %d", ret);
+ SPI_connect();
/* Now retrieve the crosstab source rows */
ret = SPI_execute(sql, true, 0);
AttInMetadata *attinmeta)
{
Tuplestorestate *tupstore = NULL;
- int ret;
MemoryContext oldcontext;
-
int serial = 1;
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- /* internal error */
- elog(ERROR, "connectby: SPI_connect returned %d", ret);
+ SPI_connect();
/* switch to longer term context to create the tuple store */
oldcontext = MemoryContextSwitchTo(per_query_ctx);
index b999b1f706656bea0cef73e6e069986756065c5b..f94b622d92f4a8d768debd16e62ca9dbf9246aad 100644 (file)
relname,
condition);
- if ((ret = SPI_connect()) < 0)
- elog(ERROR, "xpath_table: SPI_connect returned %d", ret);
+ SPI_connect();
if ((ret = SPI_exec(query_buf.data, 0)) != SPI_OK_SELECT)
elog(ERROR, "xpath_table: SPI execution failed for query %s",
index 7d154914b90762c7b7b61aa4310b6d0abaf736b5..7e2f2df965dba1034af97c21e63287ac54d5213b 100644 (file)
@@ -126,16 +126,16 @@ int SPI_connect_ext(int <parameter>options</parameter>)
</para>
</listitem>
</varlistentry>
-
- <varlistentry>
- <term><symbol>SPI_ERROR_CONNECT</symbol></term>
- <listitem>
- <para>
- on error
- </para>
- </listitem>
- </varlistentry>
</variablelist>
+
+ <para>
+ The fact that these functions return <type>int</type>
+ not <type>void</type> is historical. All failure cases are reported
+ via <function>ereport</function> or <function>elog</function>.
+ (In versions before <productname>PostgreSQL</productname> v10,
+ some but not all failures would be reported with a result value
+ of <symbol>SPI_ERROR_CONNECT</symbol>.)
+ </para>
</refsect1>
</refentry>
index 31626536a2e290d91b05acfaa9692d29cf2089de..49382d07fa85305b4f810bf48a77d544486f1272 100644 (file)
tupdesc = trigdata->tg_relation->rd_att;
/* connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- elog(ERROR, "trigf (fired %s): SPI_connect returned %d", when, ret);
+ SPI_connect();
/* get number of rows in table */
ret = SPI_exec("SELECT count(*) FROM ttest", 0);
index b2457f121a7e0505776648fb47ca276d698cdc90..010097873d1d6a68f64b947c5ee438877f22efc6 100644 (file)
@@ -639,8 +639,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
relnatts = RelationGetNumberOfAttributes(matviewRel);
/* Open SPI context. */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/* Analyze the temp table with the new contents. */
appendStringInfo(&querybuf, "ANALYZE %s", tempname);
index 62601a6d80c7be2fe44847f042bb8d2cd943f39b..25931f397f73b1253c62685c908d3a83bdd914bf 100644 (file)
break;
}
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/* Fetch or prepare a saved plan for the real check */
ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_CHECK_LOOKUPPK);
@@ -469,8 +468,7 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel,
/* Only called for non-null rows */
Assert(ri_NullCheck(RelationGetDescr(pk_rel), oldslot, riinfo, true) == RI_KEYS_NONE_NULL);
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* Fetch or prepare a saved plan for checking PK table with values coming
@@ -656,8 +654,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
return PointerGetDatum(NULL);
}
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* Fetch or prepare a saved plan for the restrict lookup (it's the same
pk_rel = trigdata->tg_relation;
oldslot = trigdata->tg_trigslot;
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/* Fetch or prepare a saved plan for the cascaded delete */
ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_CASCADE_ONDELETE);
newslot = trigdata->tg_newslot;
oldslot = trigdata->tg_trigslot;
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/* Fetch or prepare a saved plan for the cascaded update */
ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_CASCADE_ONUPDATE);
@@ -1051,8 +1046,7 @@ ri_set(TriggerData *trigdata, bool is_set_null, int tgkind)
pk_rel = trigdata->tg_relation;
oldslot = trigdata->tg_trigslot;
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* Fetch or prepare a saved plan for the trigger.
@@ -1547,8 +1541,7 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
PGC_USERSET, PGC_S_SESSION,
GUC_ACTION_SAVE, true, 0, false);
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* Generate the plan. We don't need to cache it, and there are no
@@ -1787,8 +1780,7 @@ RI_PartitionRemove_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
PGC_USERSET, PGC_S_SESSION,
GUC_ACTION_SAVE, true, 0, false);
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* Generate the plan. We don't need to cache it, and there are no
index cd9c3eddd1dd0232e90afd9da9cbe142f9e079cb..54b3542894b3acba70de44f34afacbfd46b23e7b 100644 (file)
@@ -589,8 +589,7 @@ pg_get_ruledef_worker(Oid ruleoid, int prettyFlags)
/*
* Connect to SPI manager
*/
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* On the first call prepare the plan to lookup pg_rewrite. We read
@@ -782,8 +781,7 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
/*
* Connect to SPI manager
*/
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* On the first call prepare the plan to lookup pg_rewrite. We read
index d68ad7be34556c3da75608bce51fc4eed02e6fba..fe719935c676abb3a1773a8ea583a9f8af3627f3 100644 (file)
current_call_data = &this_call_data;
- if (SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC) != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC);
select_perl_context(desc.lanpltrusted);
IsA(fcinfo->context, CallContext) &&
!castNode(CallContext, fcinfo->context)->atomic;
- if (SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0) != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0);
prodesc = compile_plperl_function(fcinfo->flinfo->fn_oid, false, false);
current_call_data->prodesc = prodesc;
int rc PG_USED_FOR_ASSERTS_ONLY;
/* Connect to SPI manager */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect();
/* Make transition tables visible to this SPI connection */
tdata = (TriggerData *) fcinfo->context;
ErrorContextCallback pl_error_context;
/* Connect to SPI manager */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect();
/* Find or compile the function */
prodesc = compile_plperl_function(fcinfo->flinfo->fn_oid, false, true);
index 980f0961bc8cafdbe5d91f144b5295f6224a0152..adfbbc8a7b7ec7006fefa0246d85eda0f6315df2 100644 (file)
/*
* Connect to SPI manager
*/
- if ((rc = SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0)) != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
+ SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0);
/* Find or compile the function */
func = plpgsql_compile(fcinfo, false);
@@ -326,8 +325,7 @@ plpgsql_inline_handler(PG_FUNCTION_ARGS)
/*
* Connect to SPI manager
*/
- if ((rc = SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC)) != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
+ SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC);
/* Compile the anonymous code block */
func = plpgsql_compile_inline(codeblock->source_text);
/*
* Connect to SPI manager (is this needed for compilation?)
*/
- if ((rc = SPI_connect()) != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
+ SPI_connect();
/*
* Set up a fake fcinfo with just enough info to satisfy
index 010a97378c9085940cead61c8de7dacaa45da709..8117e20efa23b43d042df4f689235dd664f28a3b 100644 (file)
@@ -202,8 +202,7 @@ plpython3_call_handler(PG_FUNCTION_ARGS)
!castNode(CallContext, fcinfo->context)->atomic;
/* Note: SPI_finish() happens in plpy_exec.c, which is dubious design */
- if (SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0) != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0);
/*
* Push execution context onto stack. It is important that this get
@@ -272,8 +271,7 @@ plpython3_inline_handler(PG_FUNCTION_ARGS)
PLy_initialize();
/* Note: SPI_finish() happens in plpy_exec.c, which is dubious design */
- if (SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC) != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC);
MemSet(fcinfo, 0, SizeForFunctionCallInfo(0));
MemSet(&flinfo, 0, sizeof(flinfo));
index 21b2b045933ea7a55b61868df0aa8e08bf1343fd..e2ccaa84f3fed37675308ef1478a7e850067c0b0 100644 (file)
@@ -808,8 +808,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
!castNode(CallContext, fcinfo->context)->atomic;
/* Connect to SPI manager */
- if (SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0) != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0);
/* Find or compile the function */
prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid, InvalidOid,
@@ -1072,8 +1071,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
call_state->trigdata = trigdata;
/* Connect to SPI manager */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect();
/* Make transition tables visible to this SPI connection */
rc = SPI_register_trigger_data(trigdata);
@@ -1321,8 +1319,7 @@ pltcl_event_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
int tcl_rc;
/* Connect to SPI manager */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect();
/* Find or compile the function */
prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid,
index 40c462e84e03ab20bed73f41fe5ea2491809e4f9..89ea166a67675498a1dae989e5a4ac3c8a556210 100644 (file)
@@ -220,8 +220,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS)
elog(ERROR, "not called by trigger manager");
/* Connect to the SPI manager */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "could not connect to SPI manager");
+ SPI_connect();
rc = SPI_register_trigger_data(trigdata);
Assert(rc >= 0);
index 27ac136ca5d46c675b9a15a7e7082fbc5b7ef29f..678b13ca30b60c205e268abaf499b3f4069fac59 100644 (file)
int i;
/* We use SPI to parse, plan, and execute the test query */
- if (SPI_connect() != SPI_OK_CONNECT)
- elog(ERROR, "SPI_connect failed");
+ SPI_connect();
/*
* First, plan and execute the query, and inspect the results. To the
index 14aad5a0c6e9f697059dbd0028eb890007c819bc..9e81371be4bf8961b042fd00fb60926a53318ea2 100644 (file)
newoff = Int32GetDatum((int32) DatumGetInt64(newoff));
/* Connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- elog(ERROR, "ttdummy (%s): SPI_connect returned %d", relname, ret);
+ SPI_connect();
/* Fetch tuple values and nulls */
cvals = (Datum *) palloc(natts * sizeof(Datum));