-- Uncomment the following 9 lines to use original DEPRECATED functions
--CREATE OR REPLACE FUNCTION dblink (text,text) RETURNS setof int
--  AS 'MODULE_PATHNAME','dblink' LANGUAGE 'c'
--  WITH (isstrict);
--CREATE OR REPLACE FUNCTION dblink_tok (int,int) RETURNS text
--  AS 'MODULE_PATHNAME','dblink_tok' LANGUAGE 'c'
--  WITH (isstrict);
--CREATE OR REPLACE FUNCTION dblink_last_oid (int) RETURNS oid
--  AS 'MODULE_PATHNAME','dblink_last_oid' LANGUAGE 'c'
--  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_connect (text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_connect' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_disconnect () RETURNS text
  AS 'MODULE_PATHNAME','dblink_disconnect' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_open (text,text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_open' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_fetch (text,int) RETURNS setof record
  AS 'MODULE_PATHNAME','dblink_fetch' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_close (text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_close' LANGUAGE 'c'
  WITH (isstrict);

-- Note: if this is a first time install of dblink, the following DROP
-- FUNCTION line is expected to fail.
-- Comment out the following 4 lines if the DEPRECATED functions are used.
DROP FUNCTION dblink (text,text);
CREATE OR REPLACE FUNCTION dblink (text,text) RETURNS setof record
  AS 'MODULE_PATHNAME','dblink_record' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink (text) RETURNS setof record
  AS 'MODULE_PATHNAME','dblink_record' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_exec (text,text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_exec' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_exec (text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_exec' LANGUAGE 'c'
  WITH (isstrict);

CREATE TYPE dblink_pkey_results AS (position int4, colname text);

CREATE OR REPLACE FUNCTION dblink_get_pkey (text) RETURNS setof dblink_pkey_results
  AS 'MODULE_PATHNAME','dblink_get_pkey' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_build_sql_insert (text, int2vector, int2, _text, _text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_build_sql_insert' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_build_sql_delete (text, int2vector, int2, _text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_build_sql_delete' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_build_sql_update (text, int2vector, int2, _text, _text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_build_sql_update' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION dblink_current_query () RETURNS text
  AS 'MODULE_PATHNAME','dblink_current_query' LANGUAGE 'c';

-- ******************************************************************************
CREATE OR REPLACE FUNCTION PQconnectdb (text) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Connectdb' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQsetdbLogin (text,text,text,text,text,text,text) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_SetdbLogin' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQfinish (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Finish' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQreset (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Reset' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQstatus (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Status' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQstatusStr (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_StatusStr' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQdb (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Db' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQuser (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_User' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQpass (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Password' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQhost (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Host' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQport (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Port' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQtty (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Tty' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQerrorMessage (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_ErrorMessage' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQbackendPID (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_BackendPID' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQexec (int,text) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Exec' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQresultStatus (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_ResultStatus' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQresStatus (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_ResStatus' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQresultErrorMessage (int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_ResultErrorMessage' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQclear (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Clear' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQescapeString (text) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_EscapeString' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQntuples (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Ntuples' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQnfields (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Nfields' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQfname (int,int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_Fname' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQfnumber (int,text) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Fnumber' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQftype (int,int) RETURNS oid
  AS 'MODULE_PATHNAME','dblink_pq_Ftype' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQfmod (int,int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Fmod' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQfsize (int,int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Fsize' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQBinaryTuples (int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_BinaryTuples' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQgetvalue(int,int,int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_GetValue' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQgetisnull(int,int,int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Getisnull' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQgetlength(int,int,int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_Getlength' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQcmdStatus(int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_CmdStatus' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQcmdTuples(int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_CmdTuples' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQoidValue(int) RETURNS int
  AS 'MODULE_PATHNAME','dblink_pq_OidValue' LANGUAGE 'c'
  WITH (isstrict);

CREATE OR REPLACE FUNCTION PQoidStatus(int) RETURNS text
  AS 'MODULE_PATHNAME','dblink_pq_OidStatus' LANGUAGE 'c'
  WITH (isstrict);
