C# Class NpgsqlTypes.Fastpath

This class implements the Fastpath api.
Exibir arquivo Open project: undeadlabs/Npgsql Class Usage Examples

Protected Properties

Property Type Description
conn Npgsql.NpgsqlConnection
func int>.Dictionary
stream Stream

Public Methods

Method Description
AddFunction ( String name, Int32 fnid ) : void

This adds a function to our lookup table. User code should use the addFunctions method, which is based upon a query, rather than hard coding the oid. The oid for a function is not guaranteed to remain static, even on different servers of the same version.

AddFunctions ( IDataReader rs ) : void

This takes a ResultSet containing two columns. Column 1 contains the function name, Column 2 the oid. It reads the entire ResultSet, loading the values into the function table. REMEMBER to close() the resultset after calling this!! Implementation note about function name lookups: PostgreSQL stores the function id's and their corresponding names in the pg_proc table. To speed things up locally, instead of querying each function from that table when required, a Dictionary is used. Also, only the function's required are entered into this table, keeping connection times as fast as possible. The org.postgresql.largeobject.LargeObject class performs a query upon it's startup, and passes the returned ResultSet to the addFunctions() method here. Once this has been done, the LargeObject api refers to the functions by name. Dont think that manually converting them to the oid's will work. Ok, they will for now, but they can change during development (there was some discussion about this for V7.0), so this is implemented to prevent any unwarranted headaches in the future.

Fastpath ( NpgsqlConnection conn ) : System

Initialises the fastpath system.

Fastpath ( NpgsqlConnection conn, Stream stream ) : System

Initialises the fastpath system.

FastpathCall ( Int32 fnid, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object

Send a function call to the PostgreSQL backend.

FastpathCall ( String name, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object

Send a function call to the PostgreSQL backend by name. Note: the mapping for the procedure name to function id needs to exist, usually to an earlier call to addfunction(). This is the prefered method to call, as function id's can/may change between versions of the backend. For an example of how this works, refer to NpgsqlTypes.LargeObject

GetData ( String name, NpgsqlTypes.FastpathArg args ) : Byte[]

This convenience method assumes that the return value is an Integer.

GetID ( String name ) : Int32

This returns the function id associated by its name If addFunction() or addFunctions() have not been called for this name, then an NpgsqlException is thrown.

GetInteger ( String name, NpgsqlTypes.FastpathArg args ) : Int32

This convenience method assumes that the return value is an Integer.

Private Methods

Method Description
FastpathV2 ( Int32 fnid, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object
FastpathV3 ( Int32 fnid, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object

Method Details

AddFunction() public method

This adds a function to our lookup table. User code should use the addFunctions method, which is based upon a query, rather than hard coding the oid. The oid for a function is not guaranteed to remain static, even on different servers of the same version.
public AddFunction ( String name, Int32 fnid ) : void
name String Function name.
fnid System.Int32 Function id.
return void

AddFunctions() public method

This takes a ResultSet containing two columns. Column 1 contains the function name, Column 2 the oid. It reads the entire ResultSet, loading the values into the function table. REMEMBER to close() the resultset after calling this!! Implementation note about function name lookups: PostgreSQL stores the function id's and their corresponding names in the pg_proc table. To speed things up locally, instead of querying each function from that table when required, a Dictionary is used. Also, only the function's required are entered into this table, keeping connection times as fast as possible. The org.postgresql.largeobject.LargeObject class performs a query upon it's startup, and passes the returned ResultSet to the addFunctions() method here. Once this has been done, the LargeObject api refers to the functions by name. Dont think that manually converting them to the oid's will work. Ok, they will for now, but they can change during development (there was some discussion about this for V7.0), so this is implemented to prevent any unwarranted headaches in the future.
public AddFunctions ( IDataReader rs ) : void
rs IDataReader ResultSet
return void

Fastpath() public method

Initialises the fastpath system.
public Fastpath ( NpgsqlConnection conn ) : System
conn Npgsql.NpgsqlConnection BaseConnection to attach to.
return System

Fastpath() public method

Initialises the fastpath system.
public Fastpath ( NpgsqlConnection conn, Stream stream ) : System
conn Npgsql.NpgsqlConnection BaseConnection to attach to.
stream Stream The network stream to the backend.
return System

FastpathCall() public method

Send a function call to the PostgreSQL backend.
public FastpathCall ( Int32 fnid, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object
fnid System.Int32 Function id.
resulttype System.Boolean True if the result is an integer, false for other results.
args NpgsqlTypes.FastpathArg FastpathArguments to pass to fastpath.
return Object

FastpathCall() public method

Send a function call to the PostgreSQL backend by name. Note: the mapping for the procedure name to function id needs to exist, usually to an earlier call to addfunction(). This is the prefered method to call, as function id's can/may change between versions of the backend. For an example of how this works, refer to NpgsqlTypes.LargeObject
public FastpathCall ( String name, System.Boolean resulttype, NpgsqlTypes.FastpathArg args ) : Object
name String Function name.
resulttype System.Boolean True if the result is an integer, false for other results.
args NpgsqlTypes.FastpathArg FastpathArguments to pass to fastpath.
return Object

GetData() public method

This convenience method assumes that the return value is an Integer.
public GetData ( String name, NpgsqlTypes.FastpathArg args ) : Byte[]
name String Function name.
args NpgsqlTypes.FastpathArg Function arguments.
return Byte[]

GetID() public method

This returns the function id associated by its name If addFunction() or addFunctions() have not been called for this name, then an NpgsqlException is thrown.
public GetID ( String name ) : Int32
name String Function name to lookup.
return System.Int32

GetInteger() public method

This convenience method assumes that the return value is an Integer.
public GetInteger ( String name, NpgsqlTypes.FastpathArg args ) : Int32
name String Function name.
args NpgsqlTypes.FastpathArg Function arguments.
return System.Int32

Property Details

conn protected_oe property

Our connection.
protected NpgsqlConnection,Npgsql conn
return Npgsql.NpgsqlConnection

func protected_oe property

This maps the functions names to their id's (possible unique just to a connection).
protected Dictionary func
return int>.Dictionary

stream protected_oe property

The network stream.
protected Stream stream
return Stream