Exemple #1
0
        public unsafe FastDbBuffer(string name, CLI.FieldType var_type, CLI.FieldFlags idx_flags)
        {
            buffer            = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(CLI.UnmanagedBuffer)));
              ((CLI.UnmanagedBuffer*)buffer)->fetch_data = true;
              ((CLI.UnmanagedBuffer*)buffer)->type       = (int)var_type;
              ((CLI.UnmanagedBuffer*)buffer)->size       = CLI.SizeOfCliType[(int)var_type];
              ((CLI.UnmanagedBuffer*)buffer)->capacity   = MIN_CAPACITY;
              ((CLI.UnmanagedBuffer*)buffer)->data       = Marshal.AllocCoTaskMem(MIN_CAPACITY);

              this.name  = name; //Marshal.StringToHGlobalAnsi(name);
              this.flags = (int)idx_flags;

              disposed = false;
        }
Exemple #2
0
 /// <summary>
 /// Detach current 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
 /// <seealso cref="CLI.CliDetachMode"/>
 /// </summary>
 /// <param name="mode">Optional parameter indicating the detach action.</param>
 public void Detach(CLI.CliDetachMode mode)
 {
     CLI.CliCheck(CLI.cli_detach(session, mode));
 }
Exemple #3
0
 /// <summary>
 /// Alter index on a field
 /// </summary>
 /// <param name="TableName">Name of the table</param>
 /// <param name="FieldName">Name of the field</param>
 /// <param name="NewFlags">New index types.</param>
 public void AlterIndex(string TableName, string FieldName, CLI.FieldFlags NewFlags)
 {
     CLI.CliCheck(CLI.cli_alter_index(session, TableName, FieldName, NewFlags));
 }
Exemple #4
0
 /// <summary>
 /// Add a parameter to the FastDbParameters collection.
 /// </summary>
 /// <param name="name">Parameter name (as it appears in the SQL statement) without preceeding "%".</param>
 /// <param name="param_type">Parameter type (it must match the type of the associated field).</param>
 /// <param name="capacity">Optional capacity of the underlying memory buffer.</param>
 /// <returns>A object representing the newly created parameter</returns>
 public FastDbParameter Add(string name, CLI.FieldType param_type, int capacity)
 {
     int i = items.Add(new FastDbParameter(name, param_type, capacity));
       return (FastDbParameter)items[i];
 }
Exemple #5
0
 public FastDbParameter Add(string name, CLI.FieldType param_type)
 {
     Debug.Assert(param_type >= CLI.FieldType.cli_oid && param_type < CLI.FieldType.cli_array_of_oid,
     String.Format("Parameter type {0} not supported!", Enum.GetName(typeof(CLI.FieldType), param_type)));
       return this.Add(name, param_type, 0);
 }
Exemple #6
0
 public FastDbParameter(string name, CLI.FieldType var_type, int capacity)
     : base(name, var_type, CLI.FieldFlags.cli_noindex)
 {
 }
Exemple #7
0
 /// <summary>
 /// Constructor that creates an instance of the FastDbField.  You would 
 /// normally not use it directly, but by invoking: <see cref="FastDbFields.Add"/> method.
 /// </summary>
 /// <param name="name">The name of the field.</param>
 /// <param name="var_type">The type of the field.</param>
 /// <param name="capacity">Optional capacity of the field's buffer.</param>
 public FastDbParameter(string name, CLI.FieldType var_type)
     : this(name, var_type, 0)
 {
 }
Exemple #8
0
 /// <summary>
 /// Use this method to add a field to the collection.
 /// </summary>
 /// <param name="name">Name of the field</param>
 /// <param name="field_type">Type of the field</param>
 /// <param name="index_type">Optional index to be built on the field (default: CLI.FieldFlags.no_index)</param>
 /// <param name="ref_table">Reference table name (used for inverse references). Default: null.</param>
 /// <param name="inv_ref_field">Inverse reference field name (default: null)</param>
 /// <returns></returns>
 public FastDbField Add(string name, CLI.FieldType field_type, CLI.FieldFlags index_type, string ref_table, string inv_ref_field)
 {
     int i = items.Add(new FastDbField(name, field_type, index_type, ref_table, inv_ref_field));
       return (FastDbField)items[i];
 }
Exemple #9
0
 public FastDbField Add(string name, CLI.FieldType field_type, CLI.FieldFlags index_type, string ref_table)
 {
     return Add(name, field_type, index_type, ref_table, null);
 }
Exemple #10
0
 public FastDbField Add(string name, CLI.FieldType field_type)
 {
     return Add(name, field_type, CLI.FieldFlags.cli_noindex, null, null);
 }
Exemple #11
0
   /// <summary>
   /// Field's constructor.
   /// </summary>
   /// <param name="name">Field name</param>
   /// <param name="field_type">Field type</param>
   /// <param name="idx_flags">Index types (hash/T-tree)</param>
   /// <param name="ref_table">Reference table name for inverse reference fields</param>
   /// <param name="inv_ref_field">Inverse reference field name</param>
   public FastDbField(string name, CLI.FieldType field_type, CLI.FieldFlags idx_flags, 
 string ref_table, string inv_ref_field)
       : base(name, field_type, idx_flags)
   {
       this.RefTable = ref_table;
         this.InvRefField = inv_ref_field;
   }
Exemple #12
0
        protected static unsafe void SetBufferTypeAndSize(CLI.UnmanagedBuffer* buf, 
      CLI.FieldType NewType, int NewSize, bool TypeCheck)
        {
            int n;

              if (!TypeCheck || CLI.IsArrayType(NewType))
            n = NewSize;
              else if (NewType == CLI.FieldType.cli_asciiz || NewType == CLI.FieldType.cli_pasciiz)
            n = NewSize+1;
              else
            n = CLI.SizeOfCliType[(int)NewType];

              if (n > buf->capacity) {
              buf->data = Marshal.ReAllocCoTaskMem(buf->data, ALIGN(n));
              buf->capacity = n;
              }

              buf->size = n;

              if (buf->type != (int)NewType)
            buf->type = (int)NewType;
        }
Exemple #13
0
 internal unsafe void CopyBufferData(CLI.FieldType type, int size, IntPtr data)
 {
     SetBufferTypeAndSize((CLI.UnmanagedBuffer*)buffer.ToPointer(), type, size, true);
       Int64* pend  = (Int64*)((byte*)data.ToPointer() + ALIGN(size));
       Int64* pfrom = (Int64*)data.ToPointer();
       Int64* pto   = (Int64*)((CLI.UnmanagedBuffer*)buffer.ToPointer())->data.ToPointer();
       while(pfrom < pend)
     *pto++ = *pfrom++;
       // for(int i=0; i < size; i++)
       //   *pto++ = *pfrom++;
       // Note: buffers are always aligned to 8 bytes, so we can simply copy by
       // iterating over 8 byte integers.
       //if (type == CLI.FieldType.cli_asciiz || type == CLI.FieldType.cli_pasciiz)
       //  *pto = (byte)'\0';
 }