BindFunctions() static private method

Called by SqliteBase derived classes, this function binds all user-defined functions to a connection. It is done this way so that all user-defined functions will access the database using the same encoding scheme as the connection (UTF-8 or UTF-16).
static private BindFunctions ( SqliteBase sqlbase ) : Mono.Data.Sqlite.SqliteFunction[]
sqlbase SqliteBase The base object on which the functions are to bind
return Mono.Data.Sqlite.SqliteFunction[]
Ejemplo n.º 1
0
        internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool)
        {
            if (_sql != null)
            {
                return;
            }

            _usePool = usePool;
            if (usePool)
            {
                _fileName = strFilename;
                _sql      = SqliteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
            }

            if (_sql == null)
            {
                if ((flags & SQLiteOpenFlagsEnum.Create) == 0 && FileExists(strFilename) == false)
                {
                    throw new SqliteException((int)SQLiteErrorCode.CantOpen, strFilename);
                }

                SqliteConnectionHandle db;
                int n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)flags, string.Empty);
                if (n > 0)
                {
                    throw new SqliteException(n, null);
                }

                _sql = db;
            }
            // Bind functions to this connection.  If any previous functions of the same name
            // were already bound, then the new bindings replace the old.
            _functionsArray = SqliteFunction.BindFunctions(this);
            SetTimeout(0);
        }
Ejemplo n.º 2
0
        internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool)
        {
            if (_sql != null)
            {
                return;
            }

            _usePool = usePool;
            if (usePool)
            {
                _fileName = strFilename;
                _sql      = SqliteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
            }

            if (_sql == null)
            {
                SqliteConnectionHandle db;

                if ((flags & SQLiteOpenFlagsEnum.Create) == 0 && FileExists(strFilename) == false)
                {
                    throw new SqliteException((int)SQLiteErrorCode.CantOpen, strFilename);
                }

                int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
                if (n > 0)
                {
                    throw new SqliteException(n, null);
                }

                _sql = db;
            }

            _functionsArray = SqliteFunction.BindFunctions(this);
        }
Ejemplo n.º 3
0
        internal override void Open(string strFilename)
        {
            if (_sql != IntPtr.Zero)
            {
                return;
            }
            int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out _sql);

            if (n > 0)
            {
                throw new SqliteException(n, SqliteLastError());
            }

            _functionsArray = SqliteFunction.BindFunctions(this);
        }
Ejemplo n.º 4
0
        internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool)
        {
            if (_sql != null)
            {
                return;
            }

            _usePool = usePool;
            if (usePool)
            {
                _fileName = strFilename;
                _sql      = SqliteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
            }

            if (_sql == null)
            {
                IntPtr db;

#if !SQLITE_STANDARD
                int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)flags, out db);
#else
                // Compatibility with versions < 3.5.0
                int n;

                if (UnsafeNativeMethods.use_sqlite3_open_v2)
                {
                    n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)flags, IntPtr.Zero);
                }
                else
                {
                    Console.WriteLine("Your sqlite3 version is old - please upgrade to at least v3.5.0!");
                    n = UnsafeNativeMethods.sqlite3_open(ToUTF8(strFilename), out db);
                }
#endif
                if (n > 0)
                {
                    throw new SqliteException(n, null);
                }

                _sql = db;
            }
            // Bind functions to this connection.  If any previous functions of the same name
            // were already bound, then the new bindings replace the old.
            _functionsArray = SqliteFunction.BindFunctions(this);
            SetTimeout(0);
        }
Ejemplo n.º 5
0
        internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool)
        {
            if (_sql != null)
            {
                return;
            }

            _usePool = usePool;
            if (usePool)
            {
                _fileName = strFilename;
                _sql      = SqliteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
            }

            if (_sql == null)
            {
                IntPtr db;

#if !SQLITE_STANDARD
                int n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), (int)flags, out db);
#else
                if ((flags & SQLiteOpenFlagsEnum.Create) == 0 && System.IO.File.Exists(strFilename) == false)
                {
                    throw new SqliteException((int)SQLiteErrorCode.CantOpen, strFilename);
                }

                int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
#endif
                if (n > 0)
                {
                    throw new SqliteException(n, null);
                }

                _sql = db;
            }
            _functionsArray = SqliteFunction.BindFunctions(this);
        }