/ Check-in [8cbe8f2b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add SQL function usleep() to test program tserver.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | server-process-edition
Files: files | file ages | folders
SHA3-256: 8cbe8f2b2fe0a5a246401718da8db8d487ced232ada73b53bdc9f9608c47d50e
User & Date: dan 2017-07-11 18:38:26
Context
2017-07-13
21:06
Make the freelist format a separate feature from the page-level locking. Freelist format is now configure using "PRAGMA freelist_format". check-in: dcc40797 user: dan tags: server-process-edition
2017-07-11
18:38
Add SQL function usleep() to test program tserver.c. check-in: 8cbe8f2b user: dan tags: server-process-edition
16:47
Fix a bug causing readonly mvcc connections to read the wrong cache entry in some cases. check-in: b6157267 user: dan tags: server-process-edition
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/tserver.c.

    76     76   
    77     77   static int is_eol(int i){
    78     78     return (i=='\n' || i=='\r');
    79     79   }
    80     80   static int is_whitespace(int i){
    81     81     return (i==' ' || i=='\t' || is_eol(i));
    82     82   }
           83  +
           84  +/*
           85  +** Implementation of SQL scalar function usleep().
           86  +*/
           87  +static void usleepFunc(
           88  +  sqlite3_context *context,
           89  +  int argc,
           90  +  sqlite3_value **argv
           91  +){
           92  +  int nUs;
           93  +  sqlite3_vfs *pVfs = (sqlite3_vfs*)sqlite3_user_data(context);
           94  +  assert( argc==1 );
           95  +  nUs = sqlite3_value_int64(argv[0]);
           96  +  pVfs->xSleep(pVfs, nUs);
           97  +}
    83     98   
    84     99   static void trim_string(const char **pzStr, int *pnStr){
    85    100     const char *zStr = *pzStr;
    86    101     int nStr = *pnStr;
    87    102   
    88    103     while( nStr>0 && is_whitespace(zStr[0]) ){
    89    104       zStr++;
................................................................................
   274    289   }
   275    290   
   276    291   static void *handle_client(void *pArg){
   277    292     char zCmd[32*1024];             /* Read buffer */
   278    293     int nCmd = 0;                   /* Valid bytes in zCmd[] */
   279    294     int res;                        /* Result of read() call */
   280    295     int rc = SQLITE_OK;
   281         -  int j;
   282    296   
   283    297     ClientCtx ctx;
   284    298     memset(&ctx, 0, sizeof(ClientCtx));
   285    299   
   286    300     ctx.fd = (int)(intptr_t)pArg;
   287    301     ctx.nRepeat = 1;
   288    302     rc = sqlite3_open(zDatabaseName, &ctx.db);
   289    303     if( rc!=SQLITE_OK ){
   290    304       fprintf(stderr, "sqlite3_open(): %s\n", sqlite3_errmsg(ctx.db));
   291    305       return 0;
   292    306     }
          307  +  sqlite3_create_function(
          308  +      ctx.db, "usleep", 1, SQLITE_UTF8, (void*)sqlite3_vfs_find(0), 
          309  +      usleepFunc, 0, 0
          310  +  );
   293    311   
   294    312     while( rc==SQLITE_OK ){
   295    313       int i;
   296    314       int iStart;
   297    315       int nConsume;
   298    316       res = read(ctx.fd, &zCmd[nCmd], sizeof(zCmd)-nCmd-1);
   299    317       if( res<=0 ) break;