📄 fastdbcli.cs
字号:
* Returns: * >= 0 - number of tables in the database (Metatable is not returned/counted) * < 0 - result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_show_tables( int session, //[In, Out] CliTableDescriptor[] tables ref IntPtr tables); // cli_table_descriptor** tables /*===================================================================== * cli_create_table * Create new table * Parameters: * session - session descriptor as returned by cli_open * tableName - name of new table * nFields - number of columns in the table * fields - array with table columns descriptors * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_create_table( int session, string tableName, int nFields, [In, Out] CliFieldDescriptor[] fields); // cli_field_descriptor* fields /*===================================================================== * cli_alter_table * Change table format * Parameters: * session - session descriptor as returned by cli_open * tableName - name of existing table * nFields - number of columns in the table * fields - array with new table columns descriptors * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_alter_table( int session, string tableName, int nFields, [MarshalAs(UnmanagedType.LPArray)] CliFieldDescriptor[] fields); // cli_field_descriptor* fields); /*===================================================================== * cli_drop_table * drop the table * Parameters: * session - session descriptor as returned by cli_open * tableName - name of deleted table * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_drop_table(int session, string tableName); /*===================================================================== * cli_alter_index * add or remove column index * Parameters: * session - session descriptor as returned by cli_open * tableName - name of the table * fieldName - name of field * newFlags - new flags of the field, if index exists for this field, but is not specified in * <code>newFlags</code> mask, then it will be removed; if index not exists, but is * specified in <code>newFlags</code> mask, then it will be created. * * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_alter_index( int session, string tableName, string fieldName, FieldFlags newFlags); /*===================================================================== * cli_set_error_handler * Set FastDB erro handler. Handler should be no-return function which perform stack unwind. * Parameters: * session - session descriptor as returned by cli_open * handler - error handler * Returns: * previous handler */ public delegate void CliErrorHandler(int error, [MarshalAs(UnmanagedType.LPStr)] string msg, int msgarg, IntPtr context); [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern CliErrorHandler cli_set_error_handler(int session, CliErrorHandler new_handler, IntPtr context); /*===================================================================== * cli_freeze * Freeze cursor. Make it possible to reused cursor after commit of the current transaction. * Parameters: * statement - statememt descriptor returned by cli_statement * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_freeze(int statement); /*===================================================================== * cli_unfreeze * Unfreeze cursor. Reuse previously frozen cursor. * Parameters: * statement - statememt descriptor returned by cli_statement * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_unfreeze(int statement); /*===================================================================== * cli_attach * Attach thread to the database. Each thread except one opened the database should first * attach to the database before any access to the database, and detach after end of the work with database * Parameters: * session - session descriptor returned by cli_open * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_attach(int session); /*===================================================================== * cli_detach * Detach thread from the database. Each thread except one opened the database should perform * attach to the database before any access to the database, and detach after end of the work with database * Parameters: * session - session descriptor returned by cli_open * detach_mode - bit mask representing detach mode * Returns: * result code as described in cli_result_code enum */ [Flags] public enum CliDetachMode : int { cli_commit_on_detach = 1, cli_destroy_context_on_detach = 2 }; [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_detach(int session, CliDetachMode detach_mode); /*===================================================================== * cli_free_memory * Free memory allocated by cli_show_tables and cli_describe * Parameters: * session - session descriptor returned by cli_open * ptr - pointer to the allocated buffer */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern unsafe void cli_free_memory(int session, void* ptr); [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )] public struct CliDatabaseMonitor { public int n_readers; public int n_writers; public int n_blocked_readers; public int n_blocked_writers; public int n_users; }; /*===================================================================== * cli_get_database_state * Obtain information about current state of the database * Parameters: * session - session descriptor returned by cli_open * monitor - pointer to the monitor structure. The folloing fields are set: * n_readers: number of granted shared locks * n_writers: number of granted exclusive locks * n_blocked_reader: number of threads which shared lock request was blocked * n_blocked_writers: number of threads which exclusive lock request was blocked * n_users: number of processes openned the database * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_get_database_state(int session, ref CliDatabaseMonitor monitor); /*===================================================================== * cli_set_trace_function * Set trace function which will be used to output FastDB trace messages * Parameters: * func - pointer to trace function which receives trace message terminated with new line character */ public delegate void CliTraceFunction(string msg); [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern void cli_set_trace_function(CliTraceFunction func); /*===================================================================== * cli_prepare_query * Prepare SubSQL query statement. * Parameters: * session - session descriptor returned by cli_open * query - query string with optional parameters. Parameters are specified * as '%T' where T is one or two character code of parameter type using the same notation * as in printf: %d or %i - int, %f - float or double, %ld - int8, %s - string, %p - oid... * Returns: * >= 0 - statement descriptor * < 0 - error code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_prepare_query(int session, string query); /* * cli_execute_query * Execute query previously prepared by cli_prepare_query * Parameters: * statement - statement descriptor returned by cli_prepare_query * for_update - not zero if fetched rows will be updated * record_struct - structure to receive selected record fields * ... - varying list of query parameters * Returns: * >= 0 - success, for select statements number of fetched rows is returned * < 0 - error code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_execute_query( int statement, QueryType queryType, IntPtr record_struct, // void* params object[] list); /* * cli_insert_struct * Insert new record represented as C structure * Parameters: * session - session descriptor returned by cli_open * table_name - name of the destination table * record_struct - structure specifying value of record fields * oid - pointer to the location to receive OID of created record (may be NULL) * Returns: * result code as described in cli_result_code enum */ [DllImport(libname, CharSet = CharSet.Ansi, // We want ANSI String CallingConvention = CallingConvention.Cdecl)] internal static extern int cli_insert_struct( int session, string table_name, IntPtr record_struct, // void* ref uint oid); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -