/ Check-in [f76c3a0c]
Login

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

Overview
Comment:Replace the new fprintf() calls.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | altShellFix
Files: files | file ages | folders
SHA1:f76c3a0ca40989fe9401c3b6f662f8e6ef2a730c
User & Date: mistachkin 2016-04-03 20:50:02
Context
2016-04-03
22:44
Revise and enhance the Win32 string conversion routines. check-in: 345860c9 user: mistachkin tags: altShellFix
20:50
Replace the new fprintf() calls. check-in: f76c3a0c user: mistachkin tags: altShellFix
20:45
Merge updates from trunk. check-in: 566b551e user: mistachkin tags: altShellFix
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  2034   2034   ;
  2035   2035   
  2036   2036   #if defined(SQLITE_ENABLE_SESSION)
  2037   2037   /*
  2038   2038   ** Print help information for the ".sessions" command
  2039   2039   */
  2040   2040   void session_help(ShellState *p){
  2041         -  fprintf(p->out,
         2041  +  raw_printf(p->out,
  2042   2042       ".session ?NAME? SUBCOMMAND ?ARGS...?\n"
  2043   2043       "If ?NAME? is omitted, the first defined session is used.\n"
  2044   2044       "Subcommands:\n"
  2045   2045       "   attach TABLE             Attach TABLE\n"
  2046   2046       "   changeset FILE           Write a changeset into FILE\n"
  2047   2047       "   close                    Close one session\n"
  2048   2048       "   enable ?BOOLEAN?         Set or query the enable bit\n"
................................................................................
  3898   3898       ** Invoke the sqlite3session_attach() interface to attach a particular
  3899   3899       ** table so that it is never filtered.
  3900   3900       */
  3901   3901       if( strcmp(azCmd[0],"attach")==0 ){
  3902   3902         if( nCmd!=2 ) goto session_syntax_error;
  3903   3903         if( pSession->p==0 ){
  3904   3904           session_not_open:
  3905         -        fprintf(stderr, "ERROR: No sessions are open\n");
         3905  +        raw_printf(stderr, "ERROR: No sessions are open\n");
  3906   3906         }else{
  3907   3907           rc = sqlite3session_attach(pSession->p, azCmd[1]);
  3908   3908           if( rc ){
  3909         -          fprintf(stderr, "ERROR: sqlite3session_attach() returns %d\n", rc);
         3909  +          raw_printf(stderr, "ERROR: sqlite3session_attach() returns %d\n", rc);
  3910   3910             rc = 0;
  3911   3911           }
  3912   3912         }
  3913   3913       }else
  3914   3914   
  3915   3915       /* .session changeset FILE
  3916   3916       ** .session patchset FILE
................................................................................
  3918   3918       */
  3919   3919       if( strcmp(azCmd[0],"changeset")==0 || strcmp(azCmd[0],"patchset")==0 ){
  3920   3920         FILE *out = 0;
  3921   3921         if( nCmd!=2 ) goto session_syntax_error;
  3922   3922         if( pSession->p==0 ) goto session_not_open;
  3923   3923         out = fopen(azCmd[1], "wb");
  3924   3924         if( out==0 ){
  3925         -        fprintf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
         3925  +        utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
  3926   3926         }else{
  3927   3927           int szChng;
  3928   3928           void *pChng;
  3929   3929           if( azCmd[0][0]=='c' ){
  3930   3930             rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
  3931   3931           }else{
  3932   3932             rc = sqlite3session_patchset(pSession->p, &szChng, &pChng);
................................................................................
  3933   3933           }
  3934   3934           if( rc ){
  3935   3935             printf("Error: error code %d\n", rc);
  3936   3936             rc = 0;
  3937   3937           }
  3938   3938           if( pChng 
  3939   3939             && fwrite(pChng, szChng, 1, out)!=1 ){
  3940         -          fprintf(stderr, "ERROR: Failed to write entire %d-byte output\n",
         3940  +          raw_printf(stderr, "ERROR: Failed to write entire %d-byte output\n",
  3941   3941                     szChng);
  3942   3942           }
  3943   3943           sqlite3_free(pChng);
  3944   3944           fclose(out);
  3945   3945         }
  3946   3946       }else
  3947   3947   
................................................................................
  3961   3961       */
  3962   3962       if( strcmp(azCmd[0], "enable")==0 ){
  3963   3963         int ii;
  3964   3964         if( nCmd>2 ) goto session_syntax_error;
  3965   3965         ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);
  3966   3966         if( p->nSession ){
  3967   3967           ii = sqlite3session_enable(pSession->p, ii);
  3968         -        fprintf(p->out, "session %s enable flag = %d\n", pSession->zName, ii);
         3968  +        utf8_printf(p->out, "session %s enable flag = %d\n",
         3969  +                    pSession->zName, ii);
  3969   3970         }
  3970   3971       }else
  3971   3972   
  3972   3973       /* .session filter GLOB ....
  3973   3974       ** Set a list of GLOB patterns of table names to be excluded.
  3974   3975       */
  3975   3976       if( strcmp(azCmd[0], "filter")==0 ){
................................................................................
  3979   3980           for(ii=0; ii<pSession->nFilter; ii++){
  3980   3981             sqlite3_free(pSession->azFilter[ii]);
  3981   3982           }
  3982   3983           sqlite3_free(pSession->azFilter);
  3983   3984           nByte = sizeof(pSession->azFilter[0])*(nCmd-1);
  3984   3985           pSession->azFilter = sqlite3_malloc( nByte );
  3985   3986           if( pSession->azFilter==0 ){
  3986         -          fprintf(stderr, "Error: out or memory\n");
         3987  +          raw_printf(stderr, "Error: out or memory\n");
  3987   3988             exit(1);
  3988   3989           }
  3989   3990           for(ii=1; ii<nCmd; ii++){
  3990   3991             pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]); 
  3991   3992           }
  3992   3993           pSession->nFilter = ii-1;
  3993   3994         }
................................................................................
  3998   3999       */
  3999   4000       if( strcmp(azCmd[0], "indirect")==0 ){
  4000   4001         int ii;
  4001   4002         if( nCmd>2 ) goto session_syntax_error;
  4002   4003         ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);
  4003   4004         if( p->nSession ){
  4004   4005           ii = sqlite3session_indirect(pSession->p, ii);
  4005         -        fprintf(p->out, "session %s indirect flag = %d\n", pSession->zName,ii);
         4006  +        utf8_printf(p->out, "session %s indirect flag = %d\n",
         4007  +                    pSession->zName, ii);
  4006   4008         }
  4007   4009       }else
  4008   4010   
  4009   4011       /* .session isempty
  4010   4012       ** Determine if the session is empty
  4011   4013       */
  4012   4014       if( strcmp(azCmd[0], "isempty")==0 ){
  4013   4015         int ii;
  4014   4016         if( nCmd!=1 ) goto session_syntax_error;
  4015   4017         if( p->nSession ){
  4016   4018           ii = sqlite3session_isempty(pSession->p);
  4017         -        fprintf(p->out, "session %s isempty flag = %d\n", pSession->zName, ii);
         4019  +        utf8_printf(p->out, "session %s isempty flag = %d\n",
         4020  +                    pSession->zName, ii);
  4018   4021         }
  4019   4022       }else
  4020   4023   
  4021   4024       /* .session list
  4022   4025       ** List all currently open sessions
  4023   4026       */
  4024   4027       if( strcmp(azCmd[0],"list")==0 ){
  4025   4028         for(i=0; i<p->nSession; i++){
  4026         -        fprintf(p->out, "%d %s\n", i, p->aSession[i].zName);
         4029  +        utf8_printf(p->out, "%d %s\n", i, p->aSession[i].zName);
  4027   4030         }
  4028   4031       }else
  4029   4032   
  4030   4033       /* .session open DB NAME
  4031   4034       ** Open a new session called NAME on the attached database DB.
  4032   4035       ** DB is normally "main".
  4033   4036       */
................................................................................
  4034   4037       if( strcmp(azCmd[0],"open")==0 ){
  4035   4038         char *zName;
  4036   4039         if( nCmd!=3 ) goto session_syntax_error;
  4037   4040         zName = azCmd[2];
  4038   4041         if( zName[0]==0 ) goto session_syntax_error;
  4039   4042         for(i=0; i<p->nSession; i++){
  4040   4043           if( strcmp(p->aSession[i].zName,zName)==0 ){
  4041         -          fprintf(stderr, "Session \"%s\" already exists\n", zName);
         4044  +          utf8_printf(stderr, "Session \"%s\" already exists\n", zName);
  4042   4045             goto meta_command_exit;
  4043   4046           }
  4044   4047         }
  4045   4048         if( p->nSession>=ArraySize(p->aSession) ){
  4046         -        fprintf(stderr, "Maximum of %d sessions\n", ArraySize(p->aSession));
         4049  +        raw_printf(stderr, "Maximum of %d sessions\n", ArraySize(p->aSession));
  4047   4050           goto meta_command_exit;
  4048   4051         }
  4049   4052         pSession = &p->aSession[p->nSession];
  4050   4053         rc = sqlite3session_create(p->db, azCmd[1], &pSession->p);
  4051   4054         if( rc ){
  4052         -        fprintf(stderr, "Cannot open session: error code=%d\n", rc);
         4055  +        raw_printf(stderr, "Cannot open session: error code=%d\n", rc);
  4053   4056           rc = 0;
  4054   4057           goto meta_command_exit;
  4055   4058         }
  4056   4059         pSession->nFilter = 0;
  4057   4060         sqlite3session_table_filter(pSession->p, session_filter, pSession);
  4058   4061         p->nSession++;
  4059   4062         pSession->zName = sqlite3_mprintf("%s", zName);