Changeset: 4652fa2d34c9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4652fa2d34c9
Modified Files:
clients/mapiclient/mhelp.c
tools/merovingian/client/monetdb.c
Branch: default
Log Message:
Merge with Aug2018 branch.
diffs (truncated from 351 to 300 lines):
diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -41,9 +41,7 @@ typedef struct {
const char *comments;
} SQLhelp;
-#define NUMBER_MAJOR_COMMANDS 76 // The number of major commands to show in
case of no query
-
-SQLhelp sqlhelp[] = {
+SQLhelp sqlhelp1[] = {
// major commands
{"ALTER TABLE",
"",
@@ -58,25 +56,25 @@ SQLhelp sqlhelp[] = {
"ALTER TABLE [ IF EXISTS ] qname SET { { READ | INSERT } ONLY | READ
WRITE }\n"
"ALTER TABLE [ IF EXISTS ] qname RENAME TO ident\n"
"ALTER TABLE [ IF EXISTS ] qname SET SCHEMA ident",
- "column_def,table_constraint",
+ "qname,column_def,table_constraint,ident",
"See also https://www.monetdb.org/Documentation/SQLreference/Alter"},
{"ALTER MERGE TABLE",
"",
"ALTER TABLE [ IF EXISTS ] qname ADD TABLE qname [ AS PARTITION
opt_partition_spec ]\n"
"ALTER TABLE [ IF EXISTS ] qname DROP TABLE qname [ RESTRICT | CASCADE
]\n"
"ALTER TABLE [ IF EXISTS ] qname SET TABLE qname AS PARTITION
opt_partition_spec",
- "opt_partition_spec",
+ "qname,opt_partition_spec",
"See also
https://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/DataPartitioning"},
{"ALTER SCHEMA",
"",
"ALTER SCHEMA [ IF EXISTS ] ident RENAME TO ident",
- NULL,
+ "ident",
"See also https://www.monetdb.org/Documentation/SQLreference/Alter"},
{"ALTER SEQUENCE",
"",
- "ALTER SEQUENCE ident [ AS datatype] [ RESTART [WITH start]]
[INCREMENT BY increment]\n"
+ "ALTER SEQUENCE ident [ AS data_type] [ RESTART [WITH start]]
[INCREMENT BY increment]\n"
"[MINVALUE minvalue | NO MINVALUE] [MAXVALUE maxvalue | NO MAXVALUE]
[CACHE cachevalue] [[NO] CYCLE]",
- NULL,
+ "ident,data_type",
"See also
https://www.monetdb.org/Documentation/Manuals/SQLreference/SerialTypes"},
{"ALTER USER",
"",
@@ -85,7 +83,7 @@ SQLhelp sqlhelp[] = {
"ALTER USER ident WITH [ENCRYPTED | UNENCRYPTED] PASSWORD string SET
SCHEMA schemaname\n"
"ALTER USER RENAME TO ident\n"
"ALTER USER SET [ENCRYPTED | UNENCRYPTED] PASSWORD string USING OLD
PASSWORD string",
- NULL,
+ "ident",
"See also https://www.monetdb.org/Documentation/SQLreference/Users"},
{"ANALYZE",
"Collect column data statistics for optimizations",
@@ -107,7 +105,7 @@ SQLhelp sqlhelp[] = {
"COMMENT ON { SCHEMA | TABLE | VIEW | COLUMN | INDEX | SEQUENCE |\n"
" FUNCTION | PROCEDURE | AGGREGATE | FILTER FUNCTION |
LOADER }\n"
" qname IS { 'my description text' | NULL | '' }",
- NULL,
+ "qname",
NULL},
{"COMMIT",
"Commit the current transaction",
@@ -117,7 +115,7 @@ SQLhelp sqlhelp[] = {
{"COPY BINARY",
"Append binary representations into a table",
"COPY [nrofrecords] BINARY INTO qname [column_list] FROM string [','
...] [ON { CLIENT | SERVER }] [NO CONSTRAINT]",
- "nrofrecords",
+ "nrofrecords,qname,column_list",
"See also
https://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/BinaryBulkLoad"},
{"COPY INTO",
"Parse a csv file into a table or write a query result to a csv file",
@@ -125,13 +123,13 @@ SQLhelp sqlhelp[] = {
" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT] [FWF '('
integer [',' ...] ')'\n"
"COPY [nrofrecords] INTO qname [column_list] FROM STDIN [headerlist] [
separators]\n"
" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT]\n"
- "COPY query_expression INTO [STDOUT | string [ON { CLIENT | SERVER }]]
[seps] [NULL [AS] string]",
- "nrofrecords,headerlist,separators",
+ "COPY query_expression INTO [STDOUT | string [ON { CLIENT | SERVER }]]
[separators] [NULL [AS] string]",
+ "nrofrecords,qname,column_list,headerlist,separators",
"See also
https://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/LoadingBulkData"},
{"COPY LOADER",
"Copy into using a user supplied parsing function",
"COPY LOADER INTO qname FROM qname '(' [ scalar_expression ... ] ')'",
- NULL,
+ "qname",
NULL},
{"CREATE AGGREGATE",
"",
@@ -141,7 +139,7 @@ SQLhelp sqlhelp[] = {
"CREATE [ OR REPLACE ] AGGREGATE qname '(' { '*' | [ param [',' ...]]
} ')'\n"
" RETURNS { data_type | TABLE '(' function_return [',' ...] ')' }\n"
" LANGUAGE ident external_code",
- "param,data_type,function_return",
+ "qname,param,data_type,function_return,ident",
NULL},
{"CREATE FILTER FUNCTION",
"",
@@ -199,6 +197,11 @@ SQLhelp sqlhelp[] = {
"CREATE REPLICA TABLE [ IF NOT EXISTS ] qname table_source;",
NULL,
"See also
https://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/TransactionReplication"},
+ {"CREATE ROLE",
+ "",
+ "CREATE ROLE ident [ WITH ADMIN { CURRENT_USER | CURRENT_ROLE } ]",
+ "ident",
+ NULL},
{"CREATE SCHEMA",
"",
"CREATE SCHEMA [ IF NOT EXISTS ] schema_name [default_char_set]
[path_spec] [schema_element]",
@@ -206,9 +209,9 @@ SQLhelp sqlhelp[] = {
NULL},
{"CREATE SEQUENCE",
"Define a new sequence generator",
- "CREATE SEQUENCE ident [ AS datatype] [ START [WITH start]] [INCREMENT
BY increment]\n"
+ "CREATE SEQUENCE ident [ AS data_type] [ START [WITH start]]
[INCREMENT BY increment]\n"
"[MINVALUE minvalue | NO MINVALUE] [MAXVALUE maxvalue | NO MAXVALUE]
[CACHE cachevalue] [[NO] CYCLE]",
- NULL,
+ "ident,data_type",
"See also
https://www.monetdb.org/Documentation/Manuals/SQLreference/SerialTypes"},
{"CREATE STREAM TABLE",
"Temporary table, locked during updates/ continues query processing",
@@ -233,6 +236,11 @@ SQLhelp sqlhelp[] = {
"CREATE TYPE qname EXTERNAL NAME ident",
NULL,
NULL},
+ {"CREATE USER",
+ "Create a new user",
+ "CREATE USER ident WITH [ENCRYPTED | UNENCRYPTED] PASSWORD string NAME
string SCHEMA ident",
+ "ident",
+ NULL},
{"CREATE VIEW",
"",
"CREATE [ OR REPLACE ] VIEW qname [ column_list ] AS {
query_expression | '(' query_expression ')' }\n"
@@ -400,7 +408,7 @@ SQLhelp sqlhelp[] = {
{"SELECT",
"",
"[ WITH with_list ]\n"
- "SELECT [ ALL | DISTINCT [ ON ( expression [',' ...] ) ] ]\n"
+ "SELECT [ ALL | DISTINCT [ ON { expression [',' ...] } ] ]\n"
"[ '*' | expression [ [ AS ] output_name ] [',' ...] ]\n"
"[ FROM from_item [',' ...] ]\n"
"[ WINDOW window_definition [',' ...] ]\n"
@@ -498,7 +506,9 @@ SQLhelp sqlhelp[] = {
"{ window_aggregate_function | window_rank_function } OVER { ident |
'(' window_specification ')' }",
"window_aggregate_function,window_rank_function,window_specification",
"See also
https://www.monetdb.org/Documentation/Manuals/SQLreference/WindowFunctions"},
-
+ {NULL, NULL, NULL, NULL, NULL} /* End of list marker */
+};
+SQLhelp sqlhelp2[] = {
// The subgrammar rules
{"assignment_list",
NULL,
@@ -580,9 +590,9 @@ SQLhelp sqlhelp[] = {
NULL},
{"generated_column",
NULL,
- "AUTO_INCREMENT | GENERATED ALWAYS AS IDENTITY [ '(' [ AS datatype] [
START [WITH start]] [INCREMENT BY increment]\n"
+ "AUTO_INCREMENT | GENERATED ALWAYS AS IDENTITY [ '(' [ AS data_type] [
START [WITH start]] [INCREMENT BY increment]\n"
"[MINVALUE minvalue | NO MINVALUE] [MAXVALUE maxvalue | NO MAXVALUE]
[CACHE cachevalue] [[NO] CYCLE] ')' ] ",
- NULL,
+ "data_type",
"See also
https://www.monetdb.org/Documentation/Manuals/SQLreference/SerialTypes"},
{"global_privileges",
NULL,
@@ -596,7 +606,7 @@ SQLhelp sqlhelp[] = {
NULL},
{"headerlist",
NULL,
- "'(' ( ident [string] ) [',' ...]",
+ "'(' { ident [string] } [',' ...] ')'",
NULL,
NULL},
{"ident",
@@ -607,7 +617,7 @@ SQLhelp sqlhelp[] = {
{"ident_list",
NULL,
"ident [',' ...]",
- NULL,
+ "ident",
NULL},
{"interval",
NULL,
@@ -882,16 +892,19 @@ static const char *
sql_grammar_rule(const char *word, stream *toConsole)
{
char buf[65], *s = buf;
- size_t buflen;
int i;
while (s < buf + 64 && *word != ',' && *word && !isspace((unsigned
char) *word))
*s++ = *word++;
*s = 0;
- buflen = (size_t) (s - buf);
- for (i = 0; sqlhelp[i].command; i++) {
- if (strncasecmp(sqlhelp[i].command, buf, buflen) == 0 &&
sqlhelp[i].synopsis == NULL) {
- mnstr_printf(toConsole, "%s : %s\n", buf,
sqlhelp[i].syntax);
+ for (i = 0; sqlhelp2[i].command; i++) {
+ if (strcasecmp(sqlhelp2[i].command, buf) == 0) {
+ if (sqlhelp2[i].syntax) {
+ mnstr_printf(toConsole, "%s : %s\n", buf,
sqlhelp2[i].syntax);
+ if (sqlhelp2[i].synopsis)
+ mnstr_printf(toConsole, "%.*s %s\n",
(int) (s - buf), "", sqlhelp2[i].synopsis);
+ } else if (sqlhelp2[i].synopsis)
+ mnstr_printf(toConsole, "%s : %s\n", buf,
sqlhelp2[i].synopsis);
}
}
while (*word && (isalnum((unsigned char) *word || *word == '_')))
@@ -902,36 +915,41 @@ sql_grammar_rule(const char *word, strea
}
static void
-sql_grammar(int idx, stream *toConsole)
+sql_grammar(SQLhelp *sqlhelp, stream *toConsole)
{
const char *t1;
- if (sqlhelp[idx].synopsis == NULL) {
- mnstr_printf(toConsole, "%s : %s\n", sqlhelp[idx].command,
sqlhelp[idx].syntax);
- if (sqlhelp[idx].comments)
- mnstr_printf(toConsole, "%s\n", sqlhelp[idx].comments);
+ if (sqlhelp->synopsis == NULL) {
+ mnstr_printf(toConsole, "%s : %s\n", sqlhelp->command,
sqlhelp->syntax);
+ if (sqlhelp->comments)
+ mnstr_printf(toConsole, "%s\n", sqlhelp->comments);
+ t1 = sqlhelp->rules;
+ if (t1 && *t1)
+ do
+ t1 = sql_grammar_rule(t1, toConsole);
+ while (t1);
return;
}
- if (sqlhelp[idx].command)
- mnstr_printf(toConsole, "command : %s\n",
sqlhelp[idx].command);
- if (sqlhelp[idx].synopsis && *sqlhelp[idx].synopsis)
- mnstr_printf(toConsole, "synopsis : %s\n",
sqlhelp[idx].synopsis);
- if (sqlhelp[idx].syntax && *sqlhelp[idx].syntax) {
+ if (sqlhelp->command)
+ mnstr_printf(toConsole, "command : %s\n", sqlhelp->command);
+ if (sqlhelp->synopsis && *sqlhelp->synopsis)
+ mnstr_printf(toConsole, "synopsis : %s\n", sqlhelp->synopsis);
+ if (sqlhelp->syntax && *sqlhelp->syntax) {
mnstr_printf(toConsole, "syntax : ");
- for (t1 = sqlhelp[idx].syntax; *t1; t1++) {
+ for (t1 = sqlhelp->syntax; *t1; t1++) {
if (*t1 == '\n')
mnstr_printf(toConsole, "\n ");
else
mnstr_printf(toConsole, "%c", *t1);
}
mnstr_printf(toConsole, "\n");
- t1 = sqlhelp[idx].rules;
+ t1 = sqlhelp->rules;
if (t1 && *t1)
do
t1 = sql_grammar_rule(t1, toConsole);
while (t1);
}
- if (sqlhelp[idx].comments)
- mnstr_printf(toConsole, "%s\n", sqlhelp[idx].comments);
+ if (sqlhelp->comments)
+ mnstr_printf(toConsole, "%s\n", sqlhelp->comments);
}
static void
@@ -960,28 +978,40 @@ sql_help(const char *pattern, stream *to
}
if (*pattern && *pattern != '*') {
- int first = 1;
+ bool first = true;
size_t patlen = strlen(pattern);
/* ignore possible final newline in pattern */
if (pattern[patlen - 1] == '\n')
patlen--;
- for (i = 0; *pattern && sqlhelp[i].command; i++)
- if (strncasecmp(sqlhelp[i].command, pattern, patlen) ==
0) {
+ for (i = 0; sqlhelp1[i].command; i++)
+ if (strncasecmp(sqlhelp1[i].command, pattern, patlen)
== 0) {
if (!first)
mnstr_printf(toConsole, "\n");
- sql_grammar(i, toConsole);
- first = 0;
+ sql_grammar(&sqlhelp1[i], toConsole);
+ first = false;
+ }
+ for (i = 0; sqlhelp2[i].command; i++)
+ if (strncasecmp(sqlhelp2[i].command, pattern, patlen)
== 0) {
+ if (!first)
+ mnstr_printf(toConsole, "\n");
+ sql_grammar(&sqlhelp2[i], toConsole);
+ first = false;
}
return;
}
// collect the major topics
- for (i = 0; sqlhelp[i].command; i++) {
- if (islower((unsigned char) sqlhelp[i].command[0]) && *pattern
!= '*')
- break;
+ for (i = 0; sqlhelp1[i].command; i++) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list