/ Check-in [b69f7dd1]
Login
Overview
Comment:Improved response to error conditions in the ".session" shell command and in the "changeset" command-line program.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1:b69f7dd1f35846c3bb9f4f160d50c4f03796f887
User & Date: drh 2014-08-19 00:26:17
Context
2014-08-19
00:33
Disable the hook-7.5.2 tests when using sessions, since that are not correct in that case. check-in: 6d5b9332 user: drh tags: sessions
00:26
Improved response to error conditions in the ".session" shell command and in the "changeset" command-line program. check-in: b69f7dd1 user: drh tags: sessions
2014-08-18
20:23
Fix the autoconf and MSVC makefiles so that they construct the changeset command-line utility upon request. Delete that utility program when "make clean" is run. check-in: 4dc15fe0 user: drh tags: sessions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/session/changeset.c.

228
229
230
231
232
233
234
235


236
237
238
239
240
241
242
243
...
296
297
298
299
300
301
302
303


304
305
306
307
308
309
310
311
    if( argc!=5 ) usage(argv[0]);
    out = fopen(zOut, "wb");
    if( out==0 ){
      fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
      exit(1);
    }
    readFile(argv[3], &szB, &pB);
    sqlite3changeset_concat(sz, pBuf, szB, pB, &szOut, &pOutBuf);


    if( fwrite(pOutBuf, szOut, 1, out)!=1 ){
      fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
              szOut, zOut);
    }
    fclose(out);
    sqlite3_free(pOutBuf);
    sqlite3_free(pB);
  }else
................................................................................
    const char *zOut = argv[3];
    if( argc!=4 ) usage(argv[0]);
    out = fopen(zOut, "wb");
    if( out==0 ){
      fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
      exit(1);
    }
    sqlite3changeset_invert(sz, pBuf, &szOut, &pOutBuf);


    if( fwrite(pOutBuf, szOut, 1, out)!=1 ){
      fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
              szOut, zOut);
    }
    fclose(out);
    sqlite3_free(pOutBuf);
  }else








|
>
>
|







 







|
>
>
|







228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
    if( argc!=5 ) usage(argv[0]);
    out = fopen(zOut, "wb");
    if( out==0 ){
      fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
      exit(1);
    }
    readFile(argv[3], &szB, &pB);
    rc = sqlite3changeset_concat(sz, pBuf, szB, pB, &szOut, &pOutBuf);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "sqlite3changeset_concat() returns %d\n", rc);
    }else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){
      fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
              szOut, zOut);
    }
    fclose(out);
    sqlite3_free(pOutBuf);
    sqlite3_free(pB);
  }else
................................................................................
    const char *zOut = argv[3];
    if( argc!=4 ) usage(argv[0]);
    out = fopen(zOut, "wb");
    if( out==0 ){
      fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
      exit(1);
    }
    rc = sqlite3changeset_invert(sz, pBuf, &szOut, &pOutBuf);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "sqlite3changeset_invert() returns %d\n", rc);
    }else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){
      fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
              szOut, zOut);
    }
    fclose(out);
    sqlite3_free(pOutBuf);
  }else

Changes to src/shell.c.

3228
3229
3230
3231
3232
3233
3234
3235
3236
3237




3238
3239
3240
3241
3242
3243
3244
      out = fopen(azCmd[1], "wb");
      if( out==0 ){
        fprintf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
      }else{
        int szChng;
        void *pChng;
        if( azCmd[0][0]=='c' ){
          sqlite3session_changeset(pSession->p, &szChng, &pChng);
        }else{
          sqlite3session_patchset(pSession->p, &szChng, &pChng);




        }
        if( pChng 
          && fwrite(pChng, szChng, 1, out)!=1 ){
          fprintf(stderr, "ERROR: Failed to write entire %d-byte output\n",
                  szChng);
        }
        sqlite3_free(pChng);







|

|
>
>
>
>







3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
      out = fopen(azCmd[1], "wb");
      if( out==0 ){
        fprintf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
      }else{
        int szChng;
        void *pChng;
        if( azCmd[0][0]=='c' ){
          rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
        }else{
          rc = sqlite3session_patchset(pSession->p, &szChng, &pChng);
        }
        if( rc ){
          printf("Error: error code %d\n", rc);
          rc = 0;
        }
        if( pChng 
          && fwrite(pChng, szChng, 1, out)!=1 ){
          fprintf(stderr, "ERROR: Failed to write entire %d-byte output\n",
                  szChng);
        }
        sqlite3_free(pChng);