SPI_execute_with_args <refpurpose>execute a command with out-of-line parameters</refpurpose> — 行外のパラメータを持つコマンドを実行する
int SPI_execute_with_args(const char *command, intnargs, Oid *argtypes, Datum *values, const char *nulls, boolread_only, longcount)
   <function>SPI_execute_with_args</function> executes a command that might
   include references to externally supplied parameters.  The command text
   refers to a parameter as <literal>$<replaceable>n</replaceable></literal>, and
   the call specifies data types and values for each such symbol.
   <parameter>read_only</parameter> and <parameter>count</parameter> have
   the same interpretation as in <function>SPI_execute</function>.
SPI_execute_with_argsは外部から供給されるパラメータへの参照を含むコマンドを実行します。
コマンドテキストはパラメータを$として参照し、呼び出しはこうしたシンボル毎にデータ型と値を指定します。
nread_onlyとcountはSPI_executeと同じ解釈をします。
  
   The main advantage of this routine compared to
   <function>SPI_execute</function> is that data values can be inserted
   into the command without tedious quoting/escaping, and thus with much
   less risk of SQL-injection attacks.
SPI_executeと比較して、このルーチンの主たる利点は、データ値を面倒な引用やエスケープを要せずコマンドに埋め込むことができることで、従ってSQLインジェクション攻撃の危険性を軽減します。
  
   Similar results can be achieved with <function>SPI_prepare</function> followed by
   <function>SPI_execute_plan</function>; however, when using this function
   the query plan is always customized to the specific parameter values
   provided.
   For one-time query execution, this function should be preferred.
   If the same command is to be executed with many different parameters,
   either method might be faster, depending on the cost of re-planning
   versus the benefit of custom plans.
後にSPI_execute_planが続いたSPI_prepareでも同様の結果が得られますが、この関数を使用するときには、提供された特定のパラメータ値に対して問い合わせ計画が必ずカスタマイズされます。
1回限りの問い合わせ実行に対しては、この関数を選ぶべきです。
多くの異なったパラメータを持つ同一のコマンドを実行する場合、再計画のコストと独自計画による利益に依存して、どちらか一方の方法がより早くなります。
  
const char * commandcommand string コマンド文字列
int nargs
      number of input parameters (<literal>$1</literal>, <literal>$2</literal>, etc.)
入力パラメータ($1、$2など)の数
     
Oid * argtypes
      an array of length <parameter>nargs</parameter>, containing the
      <acronym>OID</acronym>s of the data types of the parameters
パラメータのデータ型のOIDを含む、nargs長の配列
     
Datum * values
      an array of length <parameter>nargs</parameter>, containing the actual
      parameter values
実パラメータ値を含む、nargs長の配列
     
const char * nulls
      an array of length <parameter>nargs</parameter>, describing which
      parameters are null
どのパラメータがnullかを記述する、nargs長の配列
     
      If <parameter>nulls</parameter> is <symbol>NULL</symbol> then
      <function>SPI_execute_with_args</function> assumes that no parameters
      are null.  Otherwise, each entry of the <parameter>nulls</parameter>
      array should be <literal>' '</literal> if the corresponding parameter
      value is non-null, or <literal>'n'</literal> if the corresponding parameter
      value is null.  (In the latter case, the actual value in the
      corresponding <parameter>values</parameter> entry doesn't matter.)  Note
      that <parameter>nulls</parameter> is not a text string, just an array:
      it does not need a <literal>'\0'</literal> terminator.
nullsがNULLであれば、SPI_execute_with_argsはどのパラメータもnullでないと看做します。
さもなければ、nulls配列の各項目は、対応するパラメータが非NULLならば' '、対応するパラメータがNULLならば'n'です。
(後者の場合、values内の対応する値は注意されません。)
nullsはテキスト文字列ではなく単なる配列であることに注意してください。
'\0'終端は必要ありません。
     
bool read_only
読み取りのみの実行の場合true
     
long count
      maximum number of rows to return,
      or <literal>0</literal> for no limit
返される行の最大数。無制限なら0。
     
   The return value is the same as for <function>SPI_execute</function>.
戻り値はSPI_executeと同じです。
  
   <varname>SPI_processed</varname> and
   <varname>SPI_tuptable</varname> are set as in
   <function>SPI_execute</function> if successful.
成功した場合SPI_processedとSPI_tuptableはSPI_executeと同様に設定されます。