Changeset: be0f161eaccb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be0f161eaccb Modified Files: clients/mapiclient/mclient.c sql/scripts/97_comments.sql Branch: comment-on Log Message:
Display comments in mclient
diffs (90 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2533,7 +2533,6 @@ doFile(Mapi mid, stream *fp, int useinse
/* get all object names in
current schema */
char query[4096], *q = query,
*endq = query + sizeof(query);
char *name_column = hasSchema ?
"fullname" : "name";
- char *type, *name; /* output
columns */
/*
* | LINE | SCHEMA
FILTER | NAME FILTER |
@@ -2545,7 +2544,7 @@ doFile(Mapi mid, stream *fp, int useinse
* | "data.my*" | no
| fullname LIKE 'data.my%' |
* | "*a.my*" | no
| fullname LIKE '%a.my%' |
*/
- q += snprintf(q, endq - q,
"SELECT type, fullname, ntype FROM sys.describe_all_objects()\n");
+ q += snprintf(q, endq - q,
"SELECT type, fullname, remark FROM sys.describe_all_objects()\n");
q += snprintf(q, endq - q,
"WHERE (ntype & %d > 0)\n", x);
if (!wantsSystem) {
q += snprintf(q, endq -
q, "AND NOT system\n");
@@ -2561,12 +2560,31 @@ doFile(Mapi mid, stream *fp, int useinse
hdl = mapi_query(mid, query);
CHECK_RESULT(mid, hdl,
continue, buf, fp);
while (fetch_row(hdl) == 3) {
- type =
mapi_fetch_field(hdl, 0);
- name =
mapi_fetch_field(hdl, 1);
+ char *type =
mapi_fetch_field(hdl, 0);
+ char *name =
mapi_fetch_field(hdl, 1);
+ char *remark =
mapi_fetch_field(hdl, 2);
+ int type_width =
mapi_get_len(hdl, 0);
+ int name_width =
mapi_get_len(hdl, 1);
mnstr_printf(toConsole,
- "%-*s
%s\n",
-
mapi_get_len(hdl, 0), type,
- name);
+ "%-*s
%-*s",
+
type_width, type,
+
name_width * (remark != NULL), name);
+ if (remark) {
+ char *c;
+
mnstr_printf(toConsole, " '");
+ for (c =
remark; *c; c++) {
+ switch
(*c) {
+
case '\'':
+
mnstr_printf(toConsole, "''");
+
break;
+
default:
+
mnstr_writeChr(toConsole, *c);
+ }
+ }
+
mnstr_printf(toConsole, "'");
+ }
+ mnstr_printf(toConsole,
"\n");
+
}
mapi_close_handle(hdl);
hdl = NULL;
diff --git a/sql/scripts/97_comments.sql b/sql/scripts/97_comments.sql
--- a/sql/scripts/97_comments.sql
+++ b/sql/scripts/97_comments.sql
@@ -36,7 +36,8 @@ RETURNS TABLE (
fullname VARCHAR(1024),
ntype INTEGER, -- must match the MD_TABLE/VIEW/SEQ/FUNC/SCHEMA
constants in mclient.c
type VARCHAR(30),
- system BOOLEAN
+ system BOOLEAN,
+ remark VARCHAR(65000)
)
BEGIN
RETURN TABLE (
@@ -90,15 +91,18 @@ BEGIN
UNION
SELECT * FROM schema_data
)
+ --
SELECT DISTINCT
s.name AS sname,
a.name AS name,
COALESCE(s.name || '.', '') || a.name AS fullname,
a.ntype AS ntype,
(CASE WHEN a.system THEN 'SYSTEM ' ELSE '' END) || a.type
AS type,
- a.system AS system
+ a.system AS system,
+ c.remark AS remark
FROM all_data a
LEFT OUTER JOIN sys.schemas s ON a.sid = s.id
+ LEFT OUTER JOIN sys.comments c ON a.id = c.id
ORDER BY system, name, fullname, ntype
);
END;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list
