27.6. �ݾ��ӿ�

PostgreSQL �ṩһ�������������ĺ������õĽݾ��ӿڡ�

��ʾ: ����ӿ���ij�̶ֳ����Ѿ������ˣ���Ϊ���ǿ���ͨ������һ��׼���õ���������庯�����ã� �Ӷ��ﵽ���Ƶ����ܺ͸�ǿ��Ĺ��ܡ�Ȼ���ö����Ʋ����ͽ������ִ�и���䣬�滻һ�νݾ��������á�

���� PQfn ��������ͨ���ݾ��ӿ�ִ�з�����������

PGresult *PQfn(PGconn* conn,
	       int fnid,
	       int *result_buf,
	       int *result_len,
	       int result_is_int,
	       const PQArgBlock *args,
	       int nargs);

typedef struct {
    int len;
    int isint;
    union {
	int *ptr;
	int integer;
    } u;
} PQArgBlock;

fnid�����Ǵ�ִ�еĺ����Ķ����ʶ��OID���� args �� nargs ������Ҫ���ݸ������IJ����� ���DZ���ƥ���Ѿ������˵ĺ��������б� ���ij�������ṹ�� isint �ֶ����棬��ô u.integer ֵ��ָ�����ȣ�������1��2������ 4 �ֽڣ� ���������͸�����������ʱ������ǡ�����ֽ��򽻻���byte-swapping���� ��� isint Ϊ�٣���ô�� *u.ptr �����ָ���ֽ��������ݽ������κδ����ͳ�ȥ�� ��Щ���ݱ����Ƿ�����Ԥ�ڵĸú����������͵Ķ����ƴ����ʽ�� result_buf�Ƿ��÷���ֵ�Ļ������� �����߱���Ϊ����ֵ�����㹻�Ŀռ䣨����û�м�飡���� ʵ�ʵķ���ֵ���Ƚ�������result_lenָ��������ﷵ�ء� ���Ԥ�ڷ���ֵ�� 1��2���� 4 �ֽ���������result_is_int��Ϊ 1�� ������Ϊ 0����result_is_int��Ϊ 1 ���� libpq��Ҫʱ������ֵ�ֽ��������Ϳ�����ȷ�ش���ɿͻ����ϵ�����ֵ�� �� result_is_int �� 0 ʱ�����������ͻ������ֽڴ������޸�ֱ�ӷ��ء�

PQfn ���Ƿ���һ����Ч��PGresultָ�롣 ��ʹ�ý��֮ǰӦ�ü����״̬�� ���������ʹ�ú󣬵�����������ʹ�� PQclear �ͷ�PGresult��

��ע������û�취�����ֵ�IJ������յĽ����Ҳû�취��ʹ������ӿڵ�ʱ��������ֵ�Ľ����