SPI_exec(query, tcount)
String containing query plan
�䤤��碌�ײ��ޤ�ʸ����
Maximum number of tuples to return
�֤���륿�ץ�κ������
| SPI_OK_EXEC if properly disconnected |
| SPI_OK_EXEC �������¹ԤǤ�����硣 ��ʸ̮���disconnected��executed�ȿ�¬ |
| SPI_ERROR_UNCONNECTED if called from an un-connected procedure |
| SPI_ERROR_UNCONNECTED ̤��³�ʥץ� �������㤫��ƤӽФ��줿��硣 |
| SPI_ERROR_ARGUMENT if query is NULL or tcount < 0. |
| SPI_ERROR_ARGUMENT ���� query �� NULL �ޤ��� tcount < 0 �ξ�硣 |
| SPI_ERROR_UNCONNECTED if procedure is unconnected. |
| SPI_ERROR_UNCONNECTED ̤��³�ʥץ� �������㤫��ƤӽФ��줿��硣 ��Ʊ����Τ���ˤ⤢��ޤ� |
| SPI_ERROR_COPY if COPY TO/FROM stdin. |
| SPI_ERROR_COPY COPY TO/FROM stdin �ξ�硣 |
| SPI_ERROR_CURSOR if DECLARE/CLOSE CURSOR, FETCH. |
| SPI_ERROR_CURSOR DECLARE/CLOSE CURSOR, FETCH �ξ�硣 |
| SPI_ERROR_TRANSACTION if BEGIN/ABORT/END. |
| SPI_ERROR_TRANSACTION BEGIN/ABORT/END�� |
| SPI_ERROR_OPUNKNOWN if type of query is unknown (this shouldn't occur). |
| SPI_ERROR_OPUNKNOWN ̤�Τ��䤤��碌 �����פξ�硣�ʤ���Ϥ��äƤϤʤ�ޤ��� |
If execution of your query was successful then one of the following (non-negative) values will be returned:
�䤤��碌�μ¹Ԥ�����������硢�ʲ��Ρ�����Ρ��ͤΤ����줫���֤�ޤ���
| SPI_OK_UTILITY if some utility (e.g. CREATE TABLE ...) was executed |
| SPI_OK_UTILITY �桼�ƥ���ƥ����㤨�� CREATE TABLE ... �ˤ��¹Ԥ��줿��硣 |
| SPI_OK_SELECT if SELECT (but not SELECT ... INTO!) was executed |
| SPI_OK_SELECT �� SELECT ... INTO �ʳ�!�Ρ�SELECT���¹Ԥ��줿��硣 |
| SPI_OK_SELINTO if SELECT ... INTO was executed |
| SPI_OK_SELINTO SELECT ... INTO ���¹Ԥ��줿��硣 |
| SPI_OK_INSERT if INSERT (or INSERT ... SELECT) was executed |
| SPI_OK_INSERT INSERT�ʤޤ��ϡ�INSERT ... SELECT�ˤ��¹Ԥ��줿��硣 |
| SPI_OK_DELETE if DELETE was executed |
| SPI_OK_DELETE DELETE ���¹Ԥ��줿��硣 |
| SPI_OK_UPDATE if UPDATE was executed |
| SPI_OK_UPDATE UPDATE ���¹Ԥ��줿��硣 |
SPI_exec creates an execution plan (parser+planner+optimizer) and executes the query for tcount tuples.
SPI_exec �ϼ¹Էײ�ʥѡ���+�ץ���+���֥ƥ��ޥ� ���ˤ���������tcount ���� ��ʬ���䤤��碌��¹Ԥ��ޤ���
This should only be called from a connected procedure. If tcount is zero then it executes the query for all tuples returned by the query scan. Using tcount > 0 you may restrict the number of tuples for which the query will be executed. For example,
��³�ѤߤΥץ��������㤫��Τߤ��δؿ���ƤӽФ��Ʋ������� tcount �� 0 �ʤ�С��䤤 ��碌��������֤������ƤΥ��ץ�ˤĤ����䤤��碌��Ԥʤ��ޤ��� tcount > 0�Ȥ��뤳�Ȥǡ� �䤤��碌���оݤȤʤ륿�ץ�ο������¤��뤳�Ȥ��Ǥ��ޤ����㤨�С�
SPI_exec ("insert into table select * from table", 5);
will allow at most 5 tuples to be inserted into table.
If execution of your query was successful then a non-negative value will be returned.
SPI_exec ("insert into table select * from table", 5);
�Ǥϡ����� 5 �ĤΥ��ץ��ơ��֥���������뤳�Ȥ��Ǥ��ޤ����䤤��
�碌�μ¹Ԥ�����������硢������ͤ��֤�ޤ���
Note: You may pass many queries in one string or query string may be re-written by RULEs. SPI_exec returns the result for the last query executed.
1 �Ĥ�ʸ��������ʣ�����䤤��碌��������Ϥ����ꡢRULE �����ƥ�ˤ�� ��ʣ�����䤤��碌�˽��������ǽ���Τ���ʸ������Ϥ��Ƥ���ޤ� ��SPI_exec �ϺǸ�˼¹Ԥ��줿�䤤��碌�η�̤� �֤��ޤ���
The actual number of tuples for which the (last) query was executed is returned in the global variable SPI_processed (if not SPI_OK_UTILITY). If SPI_OK_SELECT returned and SPI_processed > 0 then you may use global pointer SPITupleTable *SPI_tuptable to access the selected tuples: Also NOTE, that SPI_finish frees and makes all SPITupleTables unusable! (See Memory management).
�ºݤˡʺǸ�Ρ��䤤��碌�ν����оݤȤʤä����ץ�ο��ϡ� SPI_OK_UTILITY �Ǥʤ��¤������ѿ� SPI_processed �����ꤵ��ޤ����⤷ SPI_OK_SELECT ���֤ꡢSPI_processed > 0 �ʤ�С�����ѿ��Ǥ��� SPITupleTable *SPI_tuptable�Ȥ����ݥ���Ȥ� �ơ����줿���ץ�˥��������Ǥ��ޤ����ޤ��� SPI_finish �Ϥ��٤Ƥ� SPITupleTable �������ޤ��� �ǡ�SPITupleTable �ϻ��ѤǤ��ʤ��ʤ뤳�Ȥ����դ��Ʋ��������ʥ�������� ��Ȥ��Ʋ���������
SPI_exec may return one of the following (negative) values:
SPI_exec�ϼ��Ρ���Ρ��ͤ��֤���ǽ��������ޤ���
| SPI_ERROR_ARGUMENT if query is NULL or tcount < 0. |
| SPI_ERROR_ARGUMENT ���� query �� NULL �ޤ��� tcount < 0 �ξ�硣 |
| SPI_ERROR_UNCONNECTED if procedure is unconnected. |
| SPI_ERROR_UNCONNECTED ̤��³�ʥץ���������ξ�硣 |
| SPI_ERROR_COPY if COPY TO/FROM stdin. |
| SPI_ERROR_COPY COPY TO/FROM stdin �ξ�硣 |
| SPI_ERROR_CURSOR if DECLARE/CLOSE CURSOR, FETCH. |
| SPI_ERROR_CURSOR DECLARE/CLOSE CURSOR��FETCH �ξ�硣 |
| SPI_ERROR_TRANSACTION if BEGIN/ABORT/END. |
| SPI_ERROR_TRANSACTION BEGIN/ABORT/END �ξ�硣 |
| SPI_ERROR_OPUNKNOWN if type of query is unknown (this shouldn't occur). |
| SPI_ERROR_OPUNKNOWN ̤�Τ��䤤��碌�����פξ�硣�ʤ���Ϥ��äƤϤ����ޤ��� |
SPI_exec �ϰʲ���Ԥʤ��ޤ���
Disconnects your procedure from the SPI manager and frees all memory allocations made by your procedure via palloc since the SPI_connect. These allocations can't be used any more! See Memory management.
�桼������Υץ���������� SPI �ޥ͡����㤫�����Ǥ��� SPI_connect ��¹Ԥ��Ƥ��餽�Υץ��������㤬 palloc ����Ѥ��Ƴ���������������Ƴ������� �������Υ���Ϥ�Ϥ���ѤǤ��ޤ���������ι�Ȥ��Ʋ��� ����