Hello

I use the mysql command line tool quite often and always wondered why
there's no feature that lets me quickly see the syntax of a "FOREIGN
KEY" or "GRANT" command. Now while browsing the source I found the
new "syntax" command in 4.0.12 and got the idea of implementing this
syntax help of myself. 

What do you think of a client command:
mysql> syntax select;  (or "\S" or "SHOW SYNTAX OF")
    SELECT [STRAIGHT_JOIN]
       [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
       [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY]
       [DISTINCT | DISTINCTROW | ALL]
    select_expression,...
    [INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
    [FROM table_references
      [WHERE where_definition]
      [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], ...]
      [HAVING where_definition]
      [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
      [LIMIT [offset,] rows | rows OFFSET offset]
      [PROCEDURE procedure_name(argument_list)]
      [FOR UPDATE | LOCK IN SHARE MODE]]        
   
    Reference: 6.4.1 http://www.mysql.com/doc/en/SELECT.html

I managed to hacked a working demo in less than 10 minutes which is 
simply a copy of the syntax function and which uses syntax() to pipe the
output of an arbitrary command back to mysql (of course it could be a C
function, too, but why the unnecessary burden and having it as seperate
program makes it useable standalone, too!)

This program could be a perl program which either has syntax definitions
hardcoded or, even better, is able to extract them from the docs.
A preinstalled html documentation could be prerequisite which has
two comments like "<!-- BEGIN SYNTAX: SELECT --> ... <!-- END SYNTAX -->
so that the syntax is easily extractable. Something in the kind of
        cat /usr/share/doc/mysql/en/$1.html
could be enough for the first start, too.

The final stage would then be that this help command is called whenever
on presses e.g. two times <tab> after writing a command like a command
completition.

Any suggestions and comments?

bye,

  -christian-


P.S.: Please CC me, I'm not subscribed. Thanks.
-- 
The end of the human race will be that it will eventually die of
civilization.
                -- Ralph Waldo Emerson


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to