/*
 * This file was generated automatically by xsubpp version 1.9507 from the 
 * contents of Pg.xs. Do not edit this file, edit Pg.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST! 
 *
 */

#line 1 "Pg.xs"
/*-------------------------------------------------------
 *
 * $Id: Pg.xs,v 1.16 2000/12/03 20:45:40 tgl Exp $ with patch for NULs
 *
 * Copyright (c) 1997, 1998  Edmund Mergl
 *
 *-------------------------------------------------------*/

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <string.h>
#include <stdio.h>
#include <fcntl.h>

#include "libpq-fe.h"

typedef struct pg_conn *PG_conn;
typedef struct pg_result *PG_result;

typedef struct pg_results
{
  PGresult *result;
  int row;
} PGresults;

typedef struct pg_results *PG_results;


static double
constant(name, arg)
char *name;
int arg; {
    errno = 0;
    switch (*name) {
    case 'A':
	break;
    case 'B':
	break;
    case 'C':
	break;
    case 'D':
	break;
    case 'E':
	break;
    case 'F':
	break;
    case 'G':
	break;
    case 'H':
	break;
    case 'I':
	break;
    case 'J':
	break;
    case 'K':
	break;
    case 'L':
	break;
    case 'M':
	break;
    case 'N':
	break;
    case 'O':
	break;
    case 'P':
	if (strEQ(name, "PGRES_CONNECTION_OK"))
	return 0;
	if (strEQ(name, "PGRES_CONNECTION_BAD"))
	return 1;
	if (strEQ(name, "PGRES_INV_SMGRMASK"))
	return 0x0000ffff;
	if (strEQ(name, "PGRES_INV_ARCHIVE"))
	return 0x00010000;
	if (strEQ(name, "PGRES_INV_WRITE"))
	return 0x00020000;
	if (strEQ(name, "PGRES_INV_READ"))
	return 0x00040000;
	if (strEQ(name, "PGRES_InvalidOid"))
	return 0;
	if (strEQ(name, "PGRES_EMPTY_QUERY"))
	return 0;
	if (strEQ(name, "PGRES_COMMAND_OK"))
	return 1;
	if (strEQ(name, "PGRES_TUPLES_OK"))
	return 2;
	if (strEQ(name, "PGRES_COPY_OUT"))
	return 3;
	if (strEQ(name, "PGRES_COPY_IN"))
	return 4;
	if (strEQ(name, "PGRES_BAD_RESPONSE"))
	return 5;
	if (strEQ(name, "PGRES_NONFATAL_ERROR"))
	return 6;
	if (strEQ(name, "PGRES_FATAL_ERROR"))
	return 7;
	break;
    case 'Q':
	break;
    case 'R':
	break;
    case 'S':
	break;
    case 'T':
	break;
    case 'U':
	break;
    case 'V':
	break;
    case 'W':
	break;
    case 'X':
	break;
    case 'Y':
	break;
    case 'Z':
	break;
    case 'a':
	break;
    case 'b':
	break;
    case 'c':
	break;
    case 'd':
	break;
    case 'e':
	break;
    case 'f':
	break;
    case 'g':
	break;
    case 'h':
	break;
    case 'i':
	break;
    case 'j':
	break;
    case 'k':
	break;
    case 'l':
	break;
    case 'm':
	break;
    case 'n':
	break;
    case 'o':
	break;
    case 'p':
	break;
    case 'q':
	break;
    case 'r':
	break;
    case 's':
	break;
    case 't':
	break;
    case 'u':
	break;
    case 'v':
	break;
    case 'w':
	break;
    case 'x':
	break;
    case 'y':
	break;
    case 'z':
	break;
    }
    errno = EINVAL;
    return 0;

not_there:
    errno = ENOENT;
    return 0;
}




#line 193 "Pg.c"
XS(XS_Pg_constant)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::constant(name, arg)");
    {
	char *	name = (char *)SvPV(ST(0),PL_na);
	int	arg = (int)SvIV(ST(1));
	double	RETVAL;
	dXSTARG;

	RETVAL = constant(name, arg);
	XSprePUSH; PUSHn((double)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQconnectdb)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQconnectdb(conninfo)");
    {
	char *	conninfo = (char *)SvPV(ST(0),PL_na);
	PGconn *	RETVAL;
#line 198 "Pg.xs"
		/* convert dbname to lower case if not surrounded by double quotes */
		char *ptr = strstr(conninfo, "dbname");
		if (ptr) {
			while (*ptr && *ptr != '=') {
				ptr++;
			}
                        ptr++;
			while (*ptr == ' ' || *ptr == '\t') {
				ptr++;
			}
			if (*ptr == '"') {
				*ptr++ = ' ';
				while (*ptr && *ptr != '"') {
					ptr++;
				}
				if (*ptr == '"') {
					*ptr++ = ' ';
				}
			} else {
				while (*ptr && *ptr != ' ' && *ptr != '\t') {
				      *ptr = tolower((unsigned char) *ptr);
				      ptr++;
				}
			}
		}
		RETVAL = PQconnectdb((const char *)conninfo);
#line 246 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQsetdbLogin)
{
    dXSARGS;
    if (items != 7)
	Perl_croak(aTHX_ "Usage: Pg::PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbname, login, pwd)");
    {
	char *	pghost = (char *)SvPV(ST(0),PL_na);
	char *	pgport = (char *)SvPV(ST(1),PL_na);
	char *	pgoptions = (char *)SvPV(ST(2),PL_na);
	char *	pgtty = (char *)SvPV(ST(3),PL_na);
	char *	dbname = (char *)SvPV(ST(4),PL_na);
	char *	login = (char *)SvPV(ST(5),PL_na);
	char *	pwd = (char *)SvPV(ST(6),PL_na);
	PGconn *	RETVAL;

	RETVAL = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbname, login, pwd);
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQsetdb)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: Pg::PQsetdb(pghost, pgport, pgoptions, pgtty, dbname)");
    {
	char *	pghost = (char *)SvPV(ST(0),PL_na);
	char *	pgport = (char *)SvPV(ST(1),PL_na);
	char *	pgoptions = (char *)SvPV(ST(2),PL_na);
	char *	pgtty = (char *)SvPV(ST(3),PL_na);
	char *	dbname = (char *)SvPV(ST(4),PL_na);
	PGconn *	RETVAL;

	RETVAL = PQsetdb(pghost, pgport, pgoptions, pgtty, dbname);
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQconndefaults)
{
    dXSARGS;
    if (items != 0)
	Perl_croak(aTHX_ "Usage: Pg::PQconndefaults()");
    {
	HV *	RETVAL;
#line 251 "Pg.xs"
		PQconninfoOption *infoOptions;
		RETVAL = newHV();
		if (infoOptions = PQconndefaults()) {
			PQconninfoOption *option;
			for (option = infoOptions; option->keyword != NULL; option++) {
				if (option->val != NULL) {
					hv_store(RETVAL, option->keyword, strlen(option->keyword), newSVpv(option->val, 0), 0);
				} else {
					hv_store(RETVAL, option->keyword, strlen(option->keyword), newSVpv("", 0), 0);
				}
			}
			PQconninfoFree(infoOptions);
		}
#line 316 "Pg.c"
	ST(0) = newRV((SV*)RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_Pg_PQfinish)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQfinish(conn)");
    {
	PGconn *	conn;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	PQfinish(conn);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQreset)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQreset(conn)");
    {
	PGconn *	conn;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	PQreset(conn);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQrequestCancel)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQrequestCancel(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQrequestCancel(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQdb)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQdb(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQdb(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQuser)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQuser(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQuser(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQpass)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQpass(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQpass(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQhost)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQhost(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQhost(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQport)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQport(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQport(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQtty)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQtty(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQtty(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQoptions)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQoptions(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQoptions(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQstatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQstatus(conn)");
    {
	PGconn *	conn;
	ConnStatusType	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQstatus(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQerrorMessage)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQerrorMessage(conn)");
    {
	PGconn *	conn;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQerrorMessage(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQsocket)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQsocket(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQsocket(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQbackendPID)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQbackendPID(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQbackendPID(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQtrace)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQtrace(conn, debug_port)");
    {
	PGconn *	conn;
	FILE *	debug_port = IoIFP(sv_2io(ST(1)));

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	PQtrace(conn, debug_port);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQuntrace)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQuntrace(conn)");
    {
	PGconn *	conn;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	PQuntrace(conn);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQexec)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQexec(conn, query)");
    {
	PGconn *	conn;
	char *	query = (char *)SvPV(ST(1),PL_na);
	PGresult *	RETVAL;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 354 "Pg.xs"
		RETVAL = PQexec(conn, query);
		if (! RETVAL) {
			RETVAL = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
		}
#line 701 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQnotifies)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQnotifies(conn)");
    SP -= items;
    {
	PGconn *	conn;
#line 366 "Pg.xs"
		PGnotify *notify;
#line 718 "Pg.c"

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 368 "Pg.xs"
		notify = PQnotifies(conn);
		if (notify) {
			XPUSHs(sv_2mortal(newSVpv((char *)notify->relname, 0)));
			XPUSHs(sv_2mortal(newSViv(notify->be_pid)));
			free(notify);
		}
#line 733 "Pg.c"
	PUTBACK;
	return;
    }
}

XS(XS_Pg_PQsendQuery)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQsendQuery(conn, query)");
    {
	PGconn *	conn;
	char *	query = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQsendQuery(conn, query);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetResult)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQgetResult(conn)");
    {
	PGconn *	conn;
	PGresult *	RETVAL;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 386 "Pg.xs"
		RETVAL = PQgetResult(conn);
		if (! RETVAL) {
			RETVAL = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
		}
#line 783 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQisBusy)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQisBusy(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQisBusy(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQconsumeInput)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQconsumeInput(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQconsumeInput(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetline)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQgetline(conn, string, length)");
    {
#line 407 "Pg.xs"
		SV *bufsv = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
#line 844 "Pg.c"
	PGconn *	conn;
	int	length = (int)SvIV(ST(2));
	char *	string = sv_grow(bufsv, length);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 413 "Pg.xs"
		RETVAL = PQgetline(conn, string, length);
#line 859 "Pg.c"
	sv_setpv((SV*)ST(1), string);
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQputline)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQputline(conn, string)");
    {
	PGconn *	conn;
	char *	string = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQputline(conn, string);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetlineAsync)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQgetlineAsync(conn, buffer, bufsize)");
    {
#line 428 "Pg.xs"
		SV *bufsv = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
#line 899 "Pg.c"
	PGconn *	conn;
	int	bufsize = (int)SvIV(ST(2));
	char *	buffer = sv_grow(bufsv, bufsize);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 434 "Pg.xs"
		RETVAL = PQgetlineAsync(conn, buffer, bufsize);
#line 914 "Pg.c"
	sv_setpv((SV*)ST(1), buffer);
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQputnbytes)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQputnbytes(conn, buffer, nbytes)");
    {
	PGconn *	conn;
	char *	buffer = (char *)SvPV(ST(1),PL_na);
	int	nbytes = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQputnbytes(conn, buffer, nbytes);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQendcopy)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQendcopy(conn)");
    {
	PGconn *	conn;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQendcopy(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQmakeEmptyPGresult)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQmakeEmptyPGresult(conn, status)");
    {
	PGconn *	conn;
	ExecStatusType	status = (ExecStatusType)SvIV(ST(1));
	PGresult *	RETVAL;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = PQmakeEmptyPGresult(conn, status);
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), Nullch, (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQresultStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQresultStatus(res)");
    {
	PGresult *	res;
	ExecStatusType	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQresultStatus(res);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQntuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQntuples(res)");
    {
	PGresult *	res;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQntuples(res);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQnfields)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQnfields(res)");
    {
	PGresult *	res;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQnfields(res);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQbinaryTuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQbinaryTuples(res)");
    {
	PGresult *	res;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQbinaryTuples(res);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQfname)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQfname(res, field_num)");
    {
	PGresult *	res;
	int	field_num = (int)SvIV(ST(1));
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQfname(res, field_num);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQfnumber)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQfnumber(res, field_name)");
    {
	PGresult *	res;
	char *	field_name = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQfnumber(res, field_name);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQftype)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQftype(res, field_num)");
    {
	PGresult *	res;
	int	field_num = (int)SvIV(ST(1));
	Oid	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQftype(res, field_num);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQfsize)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQfsize(res, field_num)");
    {
	PGresult *	res;
	int	field_num = (int)SvIV(ST(1));
	short	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQfsize(res, field_num);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQfmod)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: Pg::PQfmod(res, field_num)");
    {
	PGresult *	res;
	int	field_num = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQfmod(res, field_num);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQcmdStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQcmdStatus(res)");
    {
	PGresult *	res;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQcmdStatus(res);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQoidStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQoidStatus(res)");
    {
	PGresult *	res;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");
#line 517 "Pg.xs"
		RETVAL = (char *)PQoidStatus(res);
#line 1247 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQcmdTuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQcmdTuples(res)");
    {
	PGresult *	res;
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");
#line 526 "Pg.xs"
		RETVAL = (char *)PQcmdTuples(res);
#line 1271 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetvalue)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQgetvalue(res, tup_num, field_num)");
    {
	PGresult *	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	char *	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQgetvalue(res, tup_num, field_num);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetlength)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQgetlength(res, tup_num, field_num)");
    {
	PGresult *	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQgetlength(res, tup_num, field_num);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQgetisnull)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: Pg::PQgetisnull(res, tup_num, field_num)");
    {
	PGresult *	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	RETVAL = PQgetisnull(res, tup_num, field_num);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_PQclear)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::PQclear(res)");
    {
	PGresult *	res;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	PQclear(res);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQprint)
{
    dXSARGS;
    if (items < 11)
	Perl_croak(aTHX_ "Usage: Pg::PQprint(fout, res, header, align, standard, html3, expanded, pager, fieldSep, tableOpt, caption, ...)");
    {
	FILE *	fout = IoIFP(sv_2io(ST(0)));
	PGresult *	res;
	pqbool	header = (pqbool)SvIV(ST(2));
	pqbool	align = (pqbool)SvIV(ST(3));
	pqbool	standard = (pqbool)SvIV(ST(4));
	pqbool	html3 = (pqbool)SvIV(ST(5));
	pqbool	expanded = (pqbool)SvIV(ST(6));
	pqbool	pager = (pqbool)SvIV(ST(7));
	char *	fieldSep = (char *)SvPV(ST(8),PL_na);
	char *	tableOpt = (char *)SvPV(ST(9),PL_na);
	char *	caption = (char *)SvPV(ST(10),PL_na);
#line 571 "Pg.xs"
		PQprintOpt ps;
		int i;
#line 1392 "Pg.c"

	if (SvROK(ST(1))) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");
#line 574 "Pg.xs"
		ps.header    = header;
		ps.align     = align;
		ps.standard  = standard;
		ps.html3     = html3;
		ps.expanded  = expanded;
		ps.pager     = pager;
		ps.fieldSep  = fieldSep;
		ps.tableOpt  = tableOpt;
		ps.caption   = caption;
		Newz(0, ps.fieldName, items + 1 - 11, char*);
		for (i = 11; i < items; i++) {
			ps.fieldName[i - 11] = (char *)SvPV(ST(i), PL_na);
		}
		PQprint(fout, res, &ps);
		Safefree(ps.fieldName);
#line 1416 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQdisplayTuples)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: Pg::PQdisplayTuples(res, fp, fillAlign, fieldSep, printHeader, quiet)");
    {
	PGresult *	res;
	FILE *	fp = IoIFP(sv_2io(ST(1)));
	int	fillAlign = (int)SvIV(ST(2));
	char *	fieldSep = (char *)SvPV(ST(3),PL_na);
	int	printHeader = (int)SvIV(ST(4));
	int	quiet = (int)SvIV(ST(5));

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");
#line 600 "Pg.xs"
		PQdisplayTuples(res, fp, fillAlign, (const char *)fieldSep, printHeader, quiet);
#line 1442 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_PQprintTuples)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: Pg::PQprintTuples(res, fout, printAttName, terseOutput, width)");
    {
	PGresult *	res;
	FILE *	fout = IoIFP(sv_2io(ST(1)));
	int	printAttName = (int)SvIV(ST(2));
	int	terseOutput = (int)SvIV(ST(3));
	int	width = (int)SvIV(ST(4));

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PGresult *,tmp);
	}
	else
	    croak("res is not a reference");

	PQprintTuples(res, fout, printAttName, terseOutput, width);
    }
    XSRETURN_EMPTY;
}

XS(XS_Pg_lo_open)
{
    dXSARGS;
    dXSI32;
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(conn, lobjId, mode)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	int	mode = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_open(conn, lobjId, mode);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_close)
{
    dXSARGS;
    dXSI32;
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(conn, fd)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	int	fd = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_close(conn, fd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_read)
{
    dXSARGS;
    dXSI32;
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(conn, fd, buf, len)", GvNAME(CvGV(cv)));
    {
#line 634 "Pg.xs"
		SV *bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2);
#line 1531 "Pg.c"
	PGconn *	conn;
	int	fd = (int)SvIV(ST(1));
	int	len = (int)SvIV(ST(3));
	char *	buf = sv_grow(bufsv, len + 1);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");
#line 641 "Pg.xs"
		RETVAL = lo_read(conn, fd, buf, len);
		if (RETVAL > 0) {
			SvCUR_set(bufsv, RETVAL);
			*SvEND(bufsv) = '\0';
		}
#line 1551 "Pg.c"
	sv_setpvn((SV*)ST(2), buf, RETVAL);   /* to handle NULs */
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_write)
{
    dXSARGS;
    dXSI32;
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(conn, fd, buf, len)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	int	fd = (int)SvIV(ST(1));
	char *	buf = (char *)SvPV(ST(2),PL_na);
	int	len = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_write(conn, fd, buf, len);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_lseek)
{
    dXSARGS;
    dXSI32;
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(conn, fd, offset, whence)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	int	fd = (int)SvIV(ST(1));
	int	offset = (int)SvIV(ST(2));
	int	whence = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_lseek(conn, fd, offset, whence);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_creat)
{
    dXSARGS;
    dXSI32;
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(conn, mode)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	int	mode = (int)SvIV(ST(1));
	Oid	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_creat(conn, mode);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_tell)
{
    dXSARGS;
    dXSI32;
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(conn, fd)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	int	fd = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_tell(conn, fd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_unlink)
{
    dXSARGS;
    dXSI32;
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(conn, lobjId)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_unlink(conn, lobjId);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_import)
{
    dXSARGS;
    dXSI32;
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(conn, filename)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	char *	filename = (char *)SvPV(ST(1),PL_na);
	Oid	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_import(conn, filename);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_lo_export)
{
    dXSARGS;
    dXSI32;
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(conn, lobjId, filename)", GvNAME(CvGV(cv)));
    {
	PGconn *	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	char *	filename = (char *)SvPV(ST(2),PL_na);
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PGconn *,tmp);
	}
	else
	    croak("conn is not a reference");

	RETVAL = lo_export(conn, lobjId, filename);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_connectdb)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Pg::connectdb(conninfo)");
    {
	char *	conninfo = (char *)SvPV(ST(0),PL_na);
	PG_conn	RETVAL;
#line 717 "Pg.xs"
		/* convert dbname to lower case if not surrounded by double quotes */
		char *ptr = strstr(conninfo, "dbname");
		if (ptr) {
			ptr += 6;
			while (*ptr && *ptr++ != '=') {
				;
			}
			while (*ptr && (*ptr == ' ' || *ptr == '\t')) {
				ptr++;
			}
			if (*ptr == '"') {
				*ptr++ = ' ';
				while (*ptr && *ptr != '"') {
					ptr++;
				}
				if (*ptr == '"') {
					*ptr++ = ' ';
				}
			} else {
				while (*ptr && *ptr != ' ' && *ptr != '\t') {
					*ptr = tolower((unsigned char) *ptr);
					ptr++;
				}
			}
		}
		RETVAL = PQconnectdb((const char *)conninfo);
#line 1774 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_conn", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_setdbLogin)
{
    dXSARGS;
    if (items != 7)
	Perl_croak(aTHX_ "Usage: Pg::setdbLogin(pghost, pgport, pgoptions, pgtty, dbname, login, pwd)");
    {
	char *	pghost = (char *)SvPV(ST(0),PL_na);
	char *	pgport = (char *)SvPV(ST(1),PL_na);
	char *	pgoptions = (char *)SvPV(ST(2),PL_na);
	char *	pgtty = (char *)SvPV(ST(3),PL_na);
	char *	dbname = (char *)SvPV(ST(4),PL_na);
	char *	login = (char *)SvPV(ST(5),PL_na);
	char *	pwd = (char *)SvPV(ST(6),PL_na);
	PG_conn	RETVAL;
#line 757 "Pg.xs"
		RETVAL = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbname,
							  login, pwd);
#line 1798 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_conn", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_setdb)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: Pg::setdb(pghost, pgport, pgoptions, pgtty, dbname)");
    {
	char *	pghost = (char *)SvPV(ST(0),PL_na);
	char *	pgport = (char *)SvPV(ST(1),PL_na);
	char *	pgoptions = (char *)SvPV(ST(2),PL_na);
	char *	pgtty = (char *)SvPV(ST(3),PL_na);
	char *	dbname = (char *)SvPV(ST(4),PL_na);
	PG_conn	RETVAL;
#line 771 "Pg.xs"
		RETVAL = PQsetdb(pghost, pgport, pgoptions, pgtty, dbname);
#line 1819 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_conn", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_Pg_conndefaults)
{
    dXSARGS;
    if (items != 0)
	Perl_croak(aTHX_ "Usage: Pg::conndefaults()");
    {
	HV *	RETVAL;
#line 779 "Pg.xs"
		PQconninfoOption *infoOptions;
		RETVAL = newHV();
		if (infoOptions = PQconndefaults()) {
			PQconninfoOption *option;
			for (option = infoOptions; option->keyword != NULL; option++) {
				if (option->val != NULL) {
					hv_store(RETVAL, option->keyword, strlen(option->keyword), newSVpv(option->val, 0), 0);
				} else {
					hv_store(RETVAL, option->keyword, strlen(option->keyword), newSVpv("", 0), 0);
				}
			}
			PQconninfoFree(infoOptions);
		}
#line 1847 "Pg.c"
	ST(0) = newRV((SV*)RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_PG_conn_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::DESTROY(conn)");
    {
	PG_conn	conn;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not a reference");
#line 810 "Pg.xs"
		/* printf("DESTROY connection\n"); */
		PQfinish(conn);
#line 1871 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_conn_reset)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::reset(conn)");
    {
	PG_conn	conn;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	PQreset(conn);
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_conn_requestCancel)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::requestCancel(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQrequestCancel(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_db)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::db(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQdb(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_user)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::user(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQuser(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_pass)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::pass(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQpass(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_host)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::host(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQhost(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_port)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::port(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQport(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_tty)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::tty(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQtty(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_options)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::options(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQoptions(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_status)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::status(conn)");
    {
	PG_conn	conn;
	ConnStatusType	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQstatus(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_errorMessage)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::errorMessage(conn)");
    {
	PG_conn	conn;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQerrorMessage(conn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_conn_socket)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::socket(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQsocket(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_backendPID)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::backendPID(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQbackendPID(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_trace)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::trace(conn, debug_port)");
    {
	PG_conn	conn;
	FILE *	debug_port = IoIFP(sv_2io(ST(1)));

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	PQtrace(conn, debug_port);
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_conn_untrace)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::untrace(conn)");
    {
	PG_conn	conn;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	PQuntrace(conn);
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_conn_exec)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::exec(conn, query)");
    {
	PG_conn	conn;
	char *	query = (char *)SvPV(ST(1),PL_na);
	PG_results	RETVAL;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 895 "Pg.xs"
		RETVAL = (PG_results)calloc(1, sizeof(PGresults));
		if (RETVAL) {
			RETVAL->result = PQexec((PGconn *)conn, query);
			if (!RETVAL->result) {
				RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, PGRES_FATAL_ERROR);
			}
		}
#line 2237 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_results", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_notifies)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::notifies(conn)");
    SP -= items;
    {
	PG_conn	conn;
#line 910 "Pg.xs"
		PGnotify *notify;
#line 2254 "Pg.c"

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 912 "Pg.xs"
		notify = PQnotifies(conn);
		if (notify) {
			XPUSHs(sv_2mortal(newSVpv((char *)notify->relname, 0)));
			XPUSHs(sv_2mortal(newSViv(notify->be_pid)));
			free(notify);
		}
#line 2269 "Pg.c"
	PUTBACK;
	return;
    }
}

XS(XS_PG_conn_sendQuery)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::sendQuery(conn, query)");
    {
	PG_conn	conn;
	char *	query = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQsendQuery(conn, query);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_getResult)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::getResult(conn)");
    {
	PG_conn	conn;
	PG_results	RETVAL;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 930 "Pg.xs"
		RETVAL = (PG_results)calloc(1, sizeof(PGresults));
		if (RETVAL) {
			RETVAL->result = PQgetResult((PGconn *)conn);
			if (!RETVAL->result) {
				RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, PGRES_FATAL_ERROR);
			}
		}
#line 2322 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_results", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_isBusy)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::isBusy(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQisBusy(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_consumeInput)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::consumeInput(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQconsumeInput(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_getline)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_conn::getline(conn, string, length)");
    {
#line 954 "Pg.xs"
		SV *bufsv = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
#line 2383 "Pg.c"
	PG_conn	conn;
	int	length = (int)SvIV(ST(2));
	char *	string = sv_grow(bufsv, length);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 960 "Pg.xs"
		RETVAL = PQgetline(conn, string, length);
#line 2398 "Pg.c"
	sv_setpv((SV*)ST(1), string);
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_putline)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::putline(conn, string)");
    {
	PG_conn	conn;
	char *	string = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQputline(conn, string);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_getlineAsync)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_conn::getlineAsync(conn, buffer, bufsize)");
    {
#line 975 "Pg.xs"
		SV *bufsv = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
#line 2438 "Pg.c"
	PG_conn	conn;
	int	bufsize = (int)SvIV(ST(2));
	char *	buffer = sv_grow(bufsv, bufsize);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 981 "Pg.xs"
		RETVAL = PQgetline(conn, buffer, bufsize);
#line 2453 "Pg.c"
	sv_setpv((SV*)ST(1), buffer);
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_endcopy)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_conn::endcopy(conn)");
    {
	PG_conn	conn;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = PQendcopy(conn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_makeEmptyPGresult)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::makeEmptyPGresult(conn, status)");
    {
	PG_conn	conn;
	ExecStatusType	status = (ExecStatusType)SvIV(ST(1));
	PG_results	RETVAL;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 997 "Pg.xs"
		RETVAL = (PG_results)calloc(1, sizeof(PGresults));
		if (RETVAL) {
			RETVAL->result = PQmakeEmptyPGresult((PGconn *)conn, status);
		}
#line 2505 "Pg.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "PG_results", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_open)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_open(conn, lobjId, mode)");
    {
	PG_conn	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	int	mode = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_open(conn, lobjId, mode);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_close)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_close(conn, fd)");
    {
	PG_conn	conn;
	int	fd = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_close(conn, fd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_read)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_read(conn, fd, buf, len)");
    {
#line 1021 "Pg.xs"
		SV *bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2);
#line 2569 "Pg.c"
	PG_conn	conn;
	int	fd = (int)SvIV(ST(1));
	int	len = (int)SvIV(ST(3));
	char *	buf = sv_grow(bufsv, len + 1);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");
#line 1028 "Pg.xs"
		RETVAL = lo_read(conn, fd, buf, len);
		if (RETVAL > 0) {
			SvCUR_set(bufsv, RETVAL);
			*SvEND(bufsv) = '\0';
		}
#line 2589 "Pg.c"
	sv_setpvn((SV*)ST(2), buf, RETVAL);   /* to handle NULs */
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_write)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_write(conn, fd, buf, len)");
    {
	PG_conn	conn;
	int	fd = (int)SvIV(ST(1));
	char *	buf = (char *)SvPV(ST(2),PL_na);
	int	len = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_write(conn, fd, buf, len);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_lseek)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_lseek(conn, fd, offset, whence)");
    {
	PG_conn	conn;
	int	fd = (int)SvIV(ST(1));
	int	offset = (int)SvIV(ST(2));
	int	whence = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_lseek(conn, fd, offset, whence);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_creat)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_creat(conn, mode)");
    {
	PG_conn	conn;
	int	mode = (int)SvIV(ST(1));
	Oid	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_creat(conn, mode);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_tell)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_tell(conn, fd)");
    {
	PG_conn	conn;
	int	fd = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_tell(conn, fd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_unlink)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_unlink(conn, lobjId)");
    {
	PG_conn	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_unlink(conn, lobjId);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_import)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_import(conn, filename)");
    {
	PG_conn	conn;
	char *	filename = (char *)SvPV(ST(1),PL_na);
	Oid	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_import(conn, filename);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_conn_lo_export)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_conn::lo_export(conn, lobjId, filename)");
    {
	PG_conn	conn;
	Oid	lobjId = (Oid)SvIV(ST(1));
	char *	filename = (char *)SvPV(ST(2),PL_na);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_conn")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    conn = INT2PTR(PG_conn,tmp);
	}
	else
	    croak("conn is not of type PG_conn");

	RETVAL = lo_export(conn, lobjId, filename);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::DESTROY(res)");
    {
	PG_results	res;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not a reference");
#line 1096 "Pg.xs"
		/* printf("DESTROY result\n"); */
		PQclear(res->result);
		Safefree(res);
#line 2788 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_results_resultStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::resultStatus(res)");
    {
	PG_results	res;
	ExecStatusType	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1104 "Pg.xs"
		RETVAL = PQresultStatus(res->result);
#line 2811 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_ntuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::ntuples(res)");
    {
	PG_results	res;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1112 "Pg.xs"
		RETVAL = PQntuples(res->result);
#line 2835 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_nfields)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::nfields(res)");
    {
	PG_results	res;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1121 "Pg.xs"
		RETVAL = PQnfields(res->result);
#line 2859 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_binaryTuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::binaryTuples(res)");
    {
	PG_results	res;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1130 "Pg.xs"
		RETVAL = PQbinaryTuples(res->result);
#line 2883 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_fname)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_results::fname(res, field_num)");
    {
	PG_results	res;
	int	field_num = (int)SvIV(ST(1));
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1140 "Pg.xs"
		RETVAL = PQfname(res->result, field_num);
#line 2908 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_results_fnumber)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_results::fnumber(res, field_name)");
    {
	PG_results	res;
	char *	field_name = (char *)SvPV(ST(1),PL_na);
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1150 "Pg.xs"
		RETVAL = PQfnumber(res->result, field_name);
#line 2933 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_ftype)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_results::ftype(res, field_num)");
    {
	PG_results	res;
	int	field_num = (int)SvIV(ST(1));
	Oid	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1160 "Pg.xs"
		RETVAL = PQftype(res->result, field_num);
#line 2958 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_fsize)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_results::fsize(res, field_num)");
    {
	PG_results	res;
	int	field_num = (int)SvIV(ST(1));
	short	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1170 "Pg.xs"
		RETVAL = PQfsize(res->result, field_num);
#line 2983 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_fmod)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: PG_results::fmod(res, field_num)");
    {
	PG_results	res;
	int	field_num = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1180 "Pg.xs"
		RETVAL = PQfmod(res->result, field_num);
#line 3008 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_cmdStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::cmdStatus(res)");
    {
	PG_results	res;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1189 "Pg.xs"
		RETVAL = PQcmdStatus(res->result);
#line 3032 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_results_oidStatus)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::oidStatus(res)");
    {
	PG_results	res;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1198 "Pg.xs"
		RETVAL = (char *)PQoidStatus(res->result);
#line 3056 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_results_cmdTuples)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::cmdTuples(res)");
    {
	PG_results	res;
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1207 "Pg.xs"
		RETVAL = (char *)PQcmdTuples(res->result);
#line 3080 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_results_getvalue)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_results::getvalue(res, tup_num, field_num)");
    {
	PG_results	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	char *	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1218 "Pg.xs"
		RETVAL = PQgetvalue(res->result, tup_num, field_num);
#line 3106 "Pg.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_PG_results_getlength)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_results::getlength(res, tup_num, field_num)");
    {
	PG_results	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1229 "Pg.xs"
		RETVAL = PQgetlength(res->result, tup_num, field_num);
#line 3132 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_getisnull)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: PG_results::getisnull(res, tup_num, field_num)");
    {
	PG_results	res;
	int	tup_num = (int)SvIV(ST(1));
	int	field_num = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1240 "Pg.xs"
		RETVAL = PQgetisnull(res->result, tup_num, field_num);
#line 3158 "Pg.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PG_results_fetchrow)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PG_results::fetchrow(res)");
    SP -= items;
    {
	PG_results	res;

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1249 "Pg.xs"
		if (res && res->result) {
			int cols = PQnfields(res->result);
			if (PQntuples(res->result) > res->row) {
				int col = 0;
				EXTEND(sp, cols);
				while (col < cols) {
					if (PQgetisnull(res->result, res->row, col)) {
						PUSHs(&PL_sv_undef);
					} else {
						char *val = PQgetvalue(res->result, res->row, col);
						PUSHs(sv_2mortal((SV*)newSVpv(val, 0)));
					}
					++col;
				}
				++res->row;
			}
		}
#line 3197 "Pg.c"
	PUTBACK;
	return;
    }
}

XS(XS_PG_results_print)
{
    dXSARGS;
    if (items < 11)
	Perl_croak(aTHX_ "Usage: PG_results::print(res, fout, header, align, standard, html3, expanded, pager, fieldSep, tableOpt, caption, ...)");
    {
	FILE *	fout = IoIFP(sv_2io(ST(1)));
	PG_results	res;
	pqbool	header = (pqbool)SvIV(ST(2));
	pqbool	align = (pqbool)SvIV(ST(3));
	pqbool	standard = (pqbool)SvIV(ST(4));
	pqbool	html3 = (pqbool)SvIV(ST(5));
	pqbool	expanded = (pqbool)SvIV(ST(6));
	pqbool	pager = (pqbool)SvIV(ST(7));
	char *	fieldSep = (char *)SvPV(ST(8),PL_na);
	char *	tableOpt = (char *)SvPV(ST(9),PL_na);
	char *	caption = (char *)SvPV(ST(10),PL_na);
#line 1282 "Pg.xs"
		PQprintOpt ps;
		int i;
#line 3223 "Pg.c"

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1285 "Pg.xs"
		ps.header    = header;
		ps.align     = align;
		ps.standard  = standard;
		ps.html3     = html3;
		ps.expanded  = expanded;
		ps.pager     = pager;
		ps.fieldSep  = fieldSep;
		ps.tableOpt  = tableOpt;
		ps.caption   = caption;
		Newz(0, ps.fieldName, items + 1 - 11, char*);
		for (i = 11; i < items; i++) {
			ps.fieldName[i - 11] = (char *)SvPV(ST(i), PL_na);
		}
		PQprint(fout, res->result, &ps);
		Safefree(ps.fieldName);
#line 3247 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_results_displayTuples)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: PG_results::displayTuples(res, fp, fillAlign, fieldSep, printHeader, quiet)");
    {
	PG_results	res;
	FILE *	fp = IoIFP(sv_2io(ST(1)));
	int	fillAlign = (int)SvIV(ST(2));
	char *	fieldSep = (char *)SvPV(ST(3),PL_na);
	int	printHeader = (int)SvIV(ST(4));
	int	quiet = (int)SvIV(ST(5));

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1311 "Pg.xs"
		PQdisplayTuples(res->result, fp, fillAlign, (const char *)fieldSep, printHeader, quiet);
#line 3273 "Pg.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_PG_results_printTuples)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: PG_results::printTuples(res, fout, printAttName, terseOutput, width)");
    {
	PG_results	res;
	FILE *	fout = IoIFP(sv_2io(ST(1)));
	int	printAttName = (int)SvIV(ST(2));
	int	terseOutput = (int)SvIV(ST(3));
	int	width = (int)SvIV(ST(4));

	if (sv_derived_from(ST(0), "PG_results")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    res = INT2PTR(PG_results,tmp);
	}
	else
	    croak("res is not of type PG_results");
#line 1322 "Pg.xs"
		PQprintTuples(res->result, fout, printAttName, terseOutput, width);
#line 3298 "Pg.c"
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_Pg)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

    {
        CV * cv ;

        newXS("Pg::constant", XS_Pg_constant, file);
        newXS("Pg::PQconnectdb", XS_Pg_PQconnectdb, file);
        newXS("Pg::PQsetdbLogin", XS_Pg_PQsetdbLogin, file);
        newXS("Pg::PQsetdb", XS_Pg_PQsetdb, file);
        newXS("Pg::PQconndefaults", XS_Pg_PQconndefaults, file);
        newXS("Pg::PQfinish", XS_Pg_PQfinish, file);
        newXS("Pg::PQreset", XS_Pg_PQreset, file);
        newXS("Pg::PQrequestCancel", XS_Pg_PQrequestCancel, file);
        newXS("Pg::PQdb", XS_Pg_PQdb, file);
        newXS("Pg::PQuser", XS_Pg_PQuser, file);
        newXS("Pg::PQpass", XS_Pg_PQpass, file);
        newXS("Pg::PQhost", XS_Pg_PQhost, file);
        newXS("Pg::PQport", XS_Pg_PQport, file);
        newXS("Pg::PQtty", XS_Pg_PQtty, file);
        newXS("Pg::PQoptions", XS_Pg_PQoptions, file);
        newXS("Pg::PQstatus", XS_Pg_PQstatus, file);
        newXS("Pg::PQerrorMessage", XS_Pg_PQerrorMessage, file);
        newXS("Pg::PQsocket", XS_Pg_PQsocket, file);
        newXS("Pg::PQbackendPID", XS_Pg_PQbackendPID, file);
        newXS("Pg::PQtrace", XS_Pg_PQtrace, file);
        newXS("Pg::PQuntrace", XS_Pg_PQuntrace, file);
        newXS("Pg::PQexec", XS_Pg_PQexec, file);
        newXS("Pg::PQnotifies", XS_Pg_PQnotifies, file);
        newXS("Pg::PQsendQuery", XS_Pg_PQsendQuery, file);
        newXS("Pg::PQgetResult", XS_Pg_PQgetResult, file);
        newXS("Pg::PQisBusy", XS_Pg_PQisBusy, file);
        newXS("Pg::PQconsumeInput", XS_Pg_PQconsumeInput, file);
        newXS("Pg::PQgetline", XS_Pg_PQgetline, file);
        newXS("Pg::PQputline", XS_Pg_PQputline, file);
        newXS("Pg::PQgetlineAsync", XS_Pg_PQgetlineAsync, file);
        newXS("Pg::PQputnbytes", XS_Pg_PQputnbytes, file);
        newXS("Pg::PQendcopy", XS_Pg_PQendcopy, file);
        newXS("Pg::PQmakeEmptyPGresult", XS_Pg_PQmakeEmptyPGresult, file);
        newXS("Pg::PQresultStatus", XS_Pg_PQresultStatus, file);
        newXS("Pg::PQntuples", XS_Pg_PQntuples, file);
        newXS("Pg::PQnfields", XS_Pg_PQnfields, file);
        newXS("Pg::PQbinaryTuples", XS_Pg_PQbinaryTuples, file);
        newXS("Pg::PQfname", XS_Pg_PQfname, file);
        newXS("Pg::PQfnumber", XS_Pg_PQfnumber, file);
        newXS("Pg::PQftype", XS_Pg_PQftype, file);
        newXS("Pg::PQfsize", XS_Pg_PQfsize, file);
        newXS("Pg::PQfmod", XS_Pg_PQfmod, file);
        newXS("Pg::PQcmdStatus", XS_Pg_PQcmdStatus, file);
        newXS("Pg::PQoidStatus", XS_Pg_PQoidStatus, file);
        newXS("Pg::PQcmdTuples", XS_Pg_PQcmdTuples, file);
        newXS("Pg::PQgetvalue", XS_Pg_PQgetvalue, file);
        newXS("Pg::PQgetlength", XS_Pg_PQgetlength, file);
        newXS("Pg::PQgetisnull", XS_Pg_PQgetisnull, file);
        newXS("Pg::PQclear", XS_Pg_PQclear, file);
        newXS("Pg::PQprint", XS_Pg_PQprint, file);
        newXS("Pg::PQdisplayTuples", XS_Pg_PQdisplayTuples, file);
        newXS("Pg::PQprintTuples", XS_Pg_PQprintTuples, file);
        cv = newXS("Pg::PQlo_open", XS_Pg_lo_open, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_open", XS_Pg_lo_open, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::lo_close", XS_Pg_lo_close, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_close", XS_Pg_lo_close, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::PQlo_read", XS_Pg_lo_read, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_read", XS_Pg_lo_read, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_write", XS_Pg_lo_write, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_write", XS_Pg_lo_write, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_lseek", XS_Pg_lo_lseek, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_lseek", XS_Pg_lo_lseek, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_creat", XS_Pg_lo_creat, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_creat", XS_Pg_lo_creat, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::lo_tell", XS_Pg_lo_tell, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_tell", XS_Pg_lo_tell, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_unlink", XS_Pg_lo_unlink, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_unlink", XS_Pg_lo_unlink, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::PQlo_import", XS_Pg_lo_import, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_import", XS_Pg_lo_import, file);
        XSANY.any_i32 = 0 ;
        cv = newXS("Pg::PQlo_export", XS_Pg_lo_export, file);
        XSANY.any_i32 = 1 ;
        cv = newXS("Pg::lo_export", XS_Pg_lo_export, file);
        XSANY.any_i32 = 0 ;
        newXS("Pg::connectdb", XS_Pg_connectdb, file);
        newXS("Pg::setdbLogin", XS_Pg_setdbLogin, file);
        newXS("Pg::setdb", XS_Pg_setdb, file);
        newXS("Pg::conndefaults", XS_Pg_conndefaults, file);
        newXS("PG_conn::DESTROY", XS_PG_conn_DESTROY, file);
        newXS("PG_conn::reset", XS_PG_conn_reset, file);
        newXS("PG_conn::requestCancel", XS_PG_conn_requestCancel, file);
        newXS("PG_conn::db", XS_PG_conn_db, file);
        newXS("PG_conn::user", XS_PG_conn_user, file);
        newXS("PG_conn::pass", XS_PG_conn_pass, file);
        newXS("PG_conn::host", XS_PG_conn_host, file);
        newXS("PG_conn::port", XS_PG_conn_port, file);
        newXS("PG_conn::tty", XS_PG_conn_tty, file);
        newXS("PG_conn::options", XS_PG_conn_options, file);
        newXS("PG_conn::status", XS_PG_conn_status, file);
        newXS("PG_conn::errorMessage", XS_PG_conn_errorMessage, file);
        newXS("PG_conn::socket", XS_PG_conn_socket, file);
        newXS("PG_conn::backendPID", XS_PG_conn_backendPID, file);
        newXS("PG_conn::trace", XS_PG_conn_trace, file);
        newXS("PG_conn::untrace", XS_PG_conn_untrace, file);
        newXS("PG_conn::exec", XS_PG_conn_exec, file);
        newXS("PG_conn::notifies", XS_PG_conn_notifies, file);
        newXS("PG_conn::sendQuery", XS_PG_conn_sendQuery, file);
        newXS("PG_conn::getResult", XS_PG_conn_getResult, file);
        newXS("PG_conn::isBusy", XS_PG_conn_isBusy, file);
        newXS("PG_conn::consumeInput", XS_PG_conn_consumeInput, file);
        newXS("PG_conn::getline", XS_PG_conn_getline, file);
        newXS("PG_conn::putline", XS_PG_conn_putline, file);
        newXS("PG_conn::getlineAsync", XS_PG_conn_getlineAsync, file);
        newXS("PG_conn::endcopy", XS_PG_conn_endcopy, file);
        newXS("PG_conn::makeEmptyPGresult", XS_PG_conn_makeEmptyPGresult, file);
        newXS("PG_conn::lo_open", XS_PG_conn_lo_open, file);
        newXS("PG_conn::lo_close", XS_PG_conn_lo_close, file);
        newXS("PG_conn::lo_read", XS_PG_conn_lo_read, file);
        newXS("PG_conn::lo_write", XS_PG_conn_lo_write, file);
        newXS("PG_conn::lo_lseek", XS_PG_conn_lo_lseek, file);
        newXS("PG_conn::lo_creat", XS_PG_conn_lo_creat, file);
        newXS("PG_conn::lo_tell", XS_PG_conn_lo_tell, file);
        newXS("PG_conn::lo_unlink", XS_PG_conn_lo_unlink, file);
        newXS("PG_conn::lo_import", XS_PG_conn_lo_import, file);
        newXS("PG_conn::lo_export", XS_PG_conn_lo_export, file);
        newXS("PG_results::DESTROY", XS_PG_results_DESTROY, file);
        newXS("PG_results::resultStatus", XS_PG_results_resultStatus, file);
        newXS("PG_results::ntuples", XS_PG_results_ntuples, file);
        newXS("PG_results::nfields", XS_PG_results_nfields, file);
        newXS("PG_results::binaryTuples", XS_PG_results_binaryTuples, file);
        newXS("PG_results::fname", XS_PG_results_fname, file);
        newXS("PG_results::fnumber", XS_PG_results_fnumber, file);
        newXS("PG_results::ftype", XS_PG_results_ftype, file);
        newXS("PG_results::fsize", XS_PG_results_fsize, file);
        newXS("PG_results::fmod", XS_PG_results_fmod, file);
        newXS("PG_results::cmdStatus", XS_PG_results_cmdStatus, file);
        newXS("PG_results::oidStatus", XS_PG_results_oidStatus, file);
        newXS("PG_results::cmdTuples", XS_PG_results_cmdTuples, file);
        newXS("PG_results::getvalue", XS_PG_results_getvalue, file);
        newXS("PG_results::getlength", XS_PG_results_getlength, file);
        newXS("PG_results::getisnull", XS_PG_results_getisnull, file);
        newXS("PG_results::fetchrow", XS_PG_results_fetchrow, file);
        newXS("PG_results::print", XS_PG_results_print, file);
        newXS("PG_results::displayTuples", XS_PG_results_displayTuples, file);
        newXS("PG_results::printTuples", XS_PG_results_printTuples, file);
    }
    XSRETURN_YES;
}

