示例#1
1
 public FuncDef(string zName, byte iPrefEnc, short nArg, int iArg, FUNC iflags, dxStep xStep, dxFinal xFinal)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = iflags;
     this.pUserData = iArg;
     this.pNext = null;
     this.xFunc = null;
     this.xStep = xStep;
     this.xFinalize = xFinal;
     this.zName = zName;
 }
示例#2
1
 public FuncDef(short nArg, byte iPrefEnc, FUNC iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = iflags;
     this.pUserData = pUserData;
     this.pNext = pNext;
     this.xFunc = xFunc;
     this.xStep = xStep;
     this.xFinalize = xFinalize;
     this.zName = zName;
     this.pHash = pHash;
     this.pDestructor = pDestructor;
 }
示例#3
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, int iArg, FUNC iflags, dxFunc xFunc)
 {
     this.nArg      = nArg;
     this.iPrefEnc  = iPrefEnc;
     this.flags     = iflags;
     this.pUserData = iArg;
     this.pNext     = null;
     this.xFunc     = xFunc;
     this.xStep     = null;
     this.xFinalize = null;
     this.zName     = zName;
 }
示例#4
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, object arg, dxFunc xFunc, FUNC flags)
 {
     this.nArg      = nArg;
     this.iPrefEnc  = iPrefEnc;
     this.flags     = flags;
     this.pUserData = arg;
     this.pNext     = null;
     this.xFunc     = xFunc;
     this.xStep     = null;
     this.xFinalize = null;
     this.zName     = zName;
 }
示例#5
0
 public FuncDef(short nArg, byte iPrefEnc, FUNC iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor)
 {
     this.nArg        = nArg;
     this.iPrefEnc    = iPrefEnc;
     this.flags       = iflags;
     this.pUserData   = pUserData;
     this.pNext       = pNext;
     this.xFunc       = xFunc;
     this.xStep       = xStep;
     this.xFinalize   = xFinalize;
     this.zName       = zName;
     this.pHash       = pHash;
     this.pDestructor = pDestructor;
 }
示例#6
0
			public dxFinal xFinalize; //(sqlite3_context*);

			// Constructor
			public sAggs(string zName, sbyte nArg, u8 argType, u8 needCollSeq, dxStep xStep, dxFinal xFinalize)
			{
				this.zName = zName;
				this.nArg = nArg;
				this.argType = argType;
				this.needCollSeq = needCollSeq;
				this.xStep = xStep;
				this.xFinalize = xFinalize;
			}
示例#7
0
文件: main_c.cs 项目: seeseekey/CSCL
static int sqlite3_create_function16(
sqlite3 db,
string zFunctionName,
int nArg,
int eTextRep,
object p,
dxFunc xFunc,   //)(sqlite3_context*,int,sqlite3_value*),
dxStep xStep,   //)(sqlite3_context*,int,sqlite3_value*),
dxFinal xFinal  //)(sqlite3_context)
){
int rc;
string zFunc8;
sqlite3_mutex_enter(db.mutex);
Debug.Assert( 0==db.mallocFailed );
zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal, null);
sqlite3DbFree(db,ref zFunc8);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db.mutex);
return rc;
}
示例#8
0
文件: main_c.cs 项目: seeseekey/CSCL
 static int sqlite3_create_function_v2(
 sqlite3 db,
 string zFunc,
 int nArg,
 int enc,
 object p,
 dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *),
 dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *),
 dxFinal xFinal,//)(sqlite3_context)
 dxFDestroy xDestroy//)(void )
 )
 {
   int rc = SQLITE_ERROR;
   FuncDestructor pArg = null;
   sqlite3_mutex_enter( db.mutex );
   if ( xDestroy != null )
   {
     pArg = new FuncDestructor();//(FuncDestructor )sqlite3DbMallocZero(db, sizeof(FuncDestructor));
     //if( null==pArg ){
     //  xDestroy(p);
     //  goto out;
     //}
     pArg.xDestroy = xDestroy;
     pArg.pUserData = p;
   }
   rc = sqlite3CreateFunc( db, zFunc, nArg, (byte)enc, p, xFunc, xStep, xFinal, pArg );
   if ( pArg != null && pArg.nRef == 0 )
   {
     Debug.Assert( rc != SQLITE_OK );
     //xDestroy(p);
     sqlite3DbFree( db, ref pArg );
   }
   //_out:
   rc = sqlite3ApiExit( db, rc );
   sqlite3_mutex_leave( db.mutex );
   return rc;
 }
示例#9
0
文件: main_c.cs 项目: seeseekey/CSCL
 /*
 ** Create new user functions.
 */
 static public int sqlite3_create_function(
 sqlite3 db,
 string zFunc,
 int nArg,
 u8 enc,
 object p,
 dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *),
 dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *),
 dxFinal xFinal//)(sqlite3_context)
 )
 {
   return sqlite3_create_function_v2( db, zFunc, nArg, enc, p, xFunc, xStep,
                         xFinal, null );
 }
示例#10
0
文件: main_c.cs 项目: seeseekey/CSCL
    /*
    ** This function is exactly the same as sqlite3_create_function(), except
    ** that it is designed to be called by internal code. The difference is
    ** that if a malloc() fails in sqlite3_create_function(), an error code
    ** is returned and the mallocFailed flag cleared.
    */
    static int sqlite3CreateFunc(
    sqlite3 db,
    string zFunctionName,
    int nArg,
    u8 enc,
    object pUserData,
    dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *),
    dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *),
    dxFinal xFinal, //)(sqlite3_context),
    FuncDestructor pDestructor
    )
    {
      FuncDef p;
      int nName;

      Debug.Assert( sqlite3_mutex_held( db.mutex ) );
      if ( zFunctionName == null ||
      ( xFunc != null && ( xFinal != null || xStep != null ) ) ||
      ( xFunc == null && ( xFinal != null && xStep == null ) ) ||
      ( xFunc == null && ( xFinal == null && xStep != null ) ) ||
      ( nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG ) ||
      ( 255 < ( nName = sqlite3Strlen30( zFunctionName ) ) ) )
      {
        return SQLITE_MISUSE_BKPT();
      }

#if !SQLITE_OMIT_UTF16
/* If SQLITE_UTF16 is specified as the encoding type, transform this
** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
**
** If SQLITE_ANY is specified, add three versions of the function
** to the hash table.
*/
if( enc==SQLITE_UTF16 ){
enc = SQLITE_UTF16NATIVE;
}else if( enc==SQLITE_ANY ){
int rc;
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,
pUserData, xFunc, xStep, xFinal, pDestructor);
if( rc==SQLITE_OK ){
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,
pUserData, xFunc, xStep, xFinal, pDestructor);
}
if( rc!=SQLITE_OK ){
return rc;
}
enc = SQLITE_UTF16BE;
}
#else
      enc = SQLITE_UTF8;
#endif

      /* Check if an existing function is being overridden or deleted. If so,
** and there are active VMs, then return SQLITE_BUSY. If a function
** is being overridden/deleted but there are no active VMs, allow the
** operation to continue but invalidate all precompiled statements.
*/
      p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 0 );
      if ( p != null && p.iPrefEnc == enc && p.nArg == nArg )
      {
        if ( db.activeVdbeCnt != 0 )
        {
          sqlite3Error( db, SQLITE_BUSY,
          "unable to delete/modify user-function due to active statements" );
          //Debug.Assert( 0 == db.mallocFailed );
          return SQLITE_BUSY;
        }
        else
        {
          sqlite3ExpirePreparedStatements( db );
        }
      }

      p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 1 );
      Debug.Assert( p != null /*|| db.mallocFailed != 0 */ );
      //if ( p == null )
      //{
      //  return SQLITE_NOMEM;
      //}

      /* If an older version of the function with a configured destructor is
      ** being replaced invoke the destructor function here. */
      functionDestroy( db, p );

      if ( pDestructor != null )
      {
        pDestructor.nRef++;
      }
      p.pDestructor = pDestructor;
      p.flags = 0;
      p.xFunc = xFunc;
      p.xStep = xStep;
      p.xFinalize = xFinal;
      p.pUserData = pUserData;
      p.nArg = (i16)nArg;
      return SQLITE_OK;
    }
示例#11
0
 /*
 ** Create new user functions.
 */
 static public int sqlite3_create_function(
 sqlite3 db,
 string zFunctionName,
 int nArg,
 u8 enc,
 object p,
 dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value **),
 dxStep xStep,//)(sqlite3_context*,int,sqlite3_value **),
 dxFinal xFinal//)(sqlite3_context*)
 )
 {
   int rc;
   sqlite3_mutex_enter( db.mutex );
   rc = sqlite3CreateFunc( db, zFunctionName, nArg, enc, p, xFunc, xStep, xFinal );
   rc = sqlite3ApiExit( db, rc );
   sqlite3_mutex_leave( db.mutex );
   return rc;
 }
示例#12
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, object arg, dxFunc xFunc, FUNC flags)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = flags;
     this.pUserData = arg;
     this.pNext = null;
     this.xFunc = xFunc;
     this.xStep = null;
     this.xFinalize = null;
     this.zName = zName;
 }