SPI_prepare

Name

SPI_prepare --  Connects your procedure to the SPI manager. �桼������Υץ����������SPI�ޥ͡��������³���ޤ���

Synopsis

SPI_prepare(query, nargs, argtypes)

����

query

Query string

�䤤��碌ʸ����

nargs

Number of input parameters ($1 ... $nargs - as in SQL-functions)

���ϥѥ�᡼���� SQL �ؿ��ˤ����� $1 ... $nargs �ˤο���

argtypes

Pointer list of type OIDs to input arguments

���ϰ����򼨤� OID ���Υݥ��󥿤Υꥹ�ȡ�

����

void *

Pointer to an execution plan (parser+planner+optimizer)

�¹Էײ�ʥѡ���+�ץ���+���֥ƥ��ޥ����ˤ򼨤��ݥ��󥿡�

Description

SPI_prepare creates and returns an execution plan (parser+planner+optimizer) but doesn't execute the query. Should only be called from a connected procedure.

SPI_prepare �ϡ��¹ԥץ��ʥѡ���+�ץ���+���֥ƥ��ޥ����ˤ���������������� ���ޤ����䤤��碌��¹Ԥ��ޤ�����³�ѤߤΥץ��������㤫��Τ߸� �ӽФ��Ʋ�������

�Ȥ���

nargs is number of parameters ($1 ... $nargs - as in SQL-functions), and nargs may be 0 only if there is not any $1 in query.

���� nargs �ϥѥ�᡼���� SQL �ؿ��� $1 ... $nargs �ˤο��Ǥ��ꡢ �䤤��碌�� $1 ��¸�ߤ��ʤ����ˤΤ� 0 �Ȥʤ�ޤ���

Execution of prepared execution plans is sometimes much faster so this feature may be useful if the same query will be executed many times.

�����Ѥ߼¹Էײ�μ¹Ԥ����˹�®�ʾ�礬����ޤ��Τǡ�Ʊ���䤤 ��碌�򲿲��¹Ԥ���褦�ʾ��ˡ����ε�ǽ��ͭ�פǤ���

The plan returned by SPI_prepare may be used only in current invocation of the procedure since SPI_finish frees memory allocated for a plan. See SPI_saveplan.

SPI_prepare ���֤����ײ�ϡ� SPI_finish ������˳�����Ƥ������ΰ�������� ���Τǡ����߽�����Υץ�����������ǤΤߤǻ��ѤǤ��ޤ��� SPI_saveplan �򻲾Ȥ��Ʋ�������

If successful, a non-null pointer will be returned. Otherwise, you'll get a NULL plan. In both cases SPI_result will be set like the value returned by SPI_exec, except that it is set to SPI_ERROR_ARGUMENT if query is NULL or nargs < 0 or nargs > 0 && argtypes is NULL.

����������硢�� NULL �Υݥ��󥿤��֤�ޤ������Ԥ������ˤ� NULL �� �ץ���֤�ޤ����ɤ���ˤ��Ƥ� SPI_exec �������Ʊ�͡�SPI_result �����ꤵ��ޤ������������� query �� NULL���ޤ��ϡ�nargs < 0���ޤ��ϡ� nargs > 0 ���� ���� argtypes �� NULL �ξ��� SPI_ERROR_ARGUMENT �����ꤵ��ޤ���