how to disable dot commands?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how to disable dot commands?

Xingwei Lin
Hi,

Is there any way can we disable the dot commands feature in sqlite?

--
Best regards,
Xingwei Lin
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to disable dot commands?

Igor Korot
Hi,

On Sun, Jan 12, 2020 at 7:44 PM Xingwei Lin <[hidden email]> wrote:
>
> Hi,
>
> Is there any way can we disable the dot commands feature in sqlite?

Are you talking about the SQLite shell?
Why do you want to disable them? What is your specific scenario?

Thank you.

>
> --
> Best regards,
> Xingwei Lin
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to disable dot commands?

Simon Slavin-3
In reply to this post by Xingwei Lin
On 13 Jan 2020, at 1:43am, Xingwei Lin <[hidden email]> wrote:

> Is there any way can we disable the dot commands feature in sqlite?

SQLite – the library you call from C and other programming languages – does not support the dot commands.  It doesn't recognise them.  If you try to use them you will get a complaint about bad syntax.

The dot commands are part of the SQLite command line shell program.  Only this one program understands the dot commands.  The source code for this program is part of the SQLite download package.

You could make your own copy of that program which did not support the dot commands.  But that would not stop someone else from using their copy on your own database files.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to disable dot commands?

Keith Medcalf
In reply to this post by Xingwei Lin

On Sunday, 12 January, 2020 18:44, Xingwei Lin <[hidden email]> wrote:

>Is there any way can we disable the dot commands feature in sqlite?

SQLite does not process dot commands, they are commands to the shell.c SQLite Application program.

The current shell.c application currently does not have a way to omit the meta commands.

However, if you build your own you can simply search shell.c (or shell.c.in) for the function do_meta_command function definition and have it execute a "return 0;" at the top of the function after the variable declarations rather that process the meta command.  This will not remove the code that handles the meta commands but merely bypass the processing of them.

That is make it look thusly by inserting the return 0; line:

/*
** If an input line begins with "." then invoke this routine to
** process that line.
**
** Return 1 on error, 2 to exit, and 0 otherwise.
*/
static int do_meta_command(char *zLine, ShellState *p){
  int h = 1;
  int nArg = 0;
  int n, c;
  int rc = 0;
  char *azArg[52];

  return 0;

#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( p->expert.pExpert ){
    expertFinish(p, 1, 0);
  }
#endif

--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to disable dot commands?

Xingwei Lin
I like this answer!! I think I think it's the easiest way.

On Mon, Jan 13, 2020 at 10:22 AM Keith Medcalf <[hidden email]> wrote:

>
> On Sunday, 12 January, 2020 18:44, Xingwei Lin <[hidden email]>
> wrote:
>
> >Is there any way can we disable the dot commands feature in sqlite?
>
> SQLite does not process dot commands, they are commands to the shell.c
> SQLite Application program.
>
> The current shell.c application currently does not have a way to omit the
> meta commands.
>
> However, if you build your own you can simply search shell.c (or
> shell.c.in) for the function do_meta_command function definition and have
> it execute a "return 0;" at the top of the function after the variable
> declarations rather that process the meta command.  This will not remove
> the code that handles the meta commands but merely bypass the processing of
> them.
>
> That is make it look thusly by inserting the return 0; line:
>
> /*
> ** If an input line begins with "." then invoke this routine to
> ** process that line.
> **
> ** Return 1 on error, 2 to exit, and 0 otherwise.
> */
> static int do_meta_command(char *zLine, ShellState *p){
>   int h = 1;
>   int nArg = 0;
>   int n, c;
>   int rc = 0;
>   char *azArg[52];
>
>   return 0;
>
> #ifndef SQLITE_OMIT_VIRTUALTABLE
>   if( p->expert.pExpert ){
>     expertFinish(p, 1, 0);
>   }
> #endif
>
> --
> The fact that there's a Highway to Hell but only a Stairway to Heaven says
> a lot about anticipated traffic volume.
>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
Best regards,
Xingwei Lin
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users