Changeset: 2f56a2db2447 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2f56a2db2447
Added Files:
        sql/scripts/52_describe.sql
Removed Files:
        sql/scripts/30_describe.sql
Modified Files:
        sql/backends/monet5/CMakeLists.txt
        sql/scripts/CMakeLists.txt
Branch: mtest
Log Message:

Use sys.table_types to get table type instead of hardcoding.


diffs (84 lines):

diff --git a/sql/backends/monet5/CMakeLists.txt 
b/sql/backends/monet5/CMakeLists.txt
--- a/sql/backends/monet5/CMakeLists.txt
+++ b/sql/backends/monet5/CMakeLists.txt
@@ -28,13 +28,13 @@ set(include_sql_files
   25_debug
   26_sysmon
   27_rejects
-  30_describe
   39_analytics
   40_json
   41_md5sum
   45_uuid
   46_profiler
   51_sys_schema_extension
+  52_describe
   58_hot_snapshot
   60_wlcr
   61_wlcr
diff --git a/sql/scripts/30_describe.sql b/sql/scripts/52_describe.sql
rename from sql/scripts/30_describe.sql
rename to sql/scripts/52_describe.sql
--- a/sql/scripts/30_describe.sql
+++ b/sql/scripts/52_describe.sql
@@ -1,30 +1,30 @@
-
+-- This Source Code Form is subject to the terms of the Mozilla Public
+-- License, v. 2.0.  If a copy of the MPL was not distributed with this
+-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
+--
+-- Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
 
 create function describe_table(schemaName string, tableName string)
        returns table(name string, query string, type string, id integer, 
remark string)
 BEGIN
-       return SELECT t.name, t.query, 
-                       CASE 
-                               WHEN t.type = 0 THEN 'TABLE' 
-                               WHEN t.type = 1 THEN 'VIEW' 
-                               WHEN t.type = 3 THEN 'MERGE TABLE' 
-                               WHEN t.type = 4 THEN 'STREAM TABLE' 
-                               WHEN t.type = 5 THEN 'REMOTE TABLE' 
-                               ELSE 'REPLICA TABLE' 
-                       END, t.id, c.remark 
-               FROM sys.schemas s, sys._tables t 
-               LEFT OUTER JOIN sys.comments c ON t.id = c.id 
-                       WHERE s.name = schemaName
-                       AND t.schema_id = s.id 
-                       AND t.name = tableName;
+       RETURN SELECT t.name, t.query, tt.table_type_name, t.id, c.remark 
+               FROM sys.schemas s, sys.table_types tt, sys._tables t
+               LEFT OUTER JOIN sys.comments c ON t.id = c.id
+                       WHERE s.name = schemaName
+                       AND t.schema_id = s.id 
+                       AND t.name = tableName
+                       AND t.type = tt.table_type_id;
 END;
 
 create function describe_columns(schemaName string, tableName string)
        returns table(name string, type string, digits integer, scale integer, 
Nulls boolean, cDefault string, number integer, remark string)
 BEGIN
        return SELECT c.name, c."type", c.type_digits, c.type_scale, c."null", 
c."default", c.number, com.remark 
-             FROM sys._tables t, sys.schemas s, sys._columns c 
-       LEFT OUTER JOIN sys.comments com ON c.id = com.id 
-             WHERE c.table_id = t.id AND t.name = tableName AND t.schema_id = 
s.id AND s.name = schemaName
-             ORDER BY c.number;
+               FROM sys._tables t, sys.schemas s, sys._columns c 
+               LEFT OUTER JOIN sys.comments com ON c.id = com.id 
+                       WHERE c.table_id = t.id
+                       AND t.name = tableName
+                       AND t.schema_id = s.id
+                       AND s.name = schemaName
+               ORDER BY c.number;
 END;
diff --git a/sql/scripts/CMakeLists.txt b/sql/scripts/CMakeLists.txt
--- a/sql/scripts/CMakeLists.txt
+++ b/sql/scripts/CMakeLists.txt
@@ -28,6 +28,7 @@ install(FILES
   45_uuid.sql
   46_profiler.sql
   51_sys_schema_extension.sql
+  52_describe.sql
   58_hot_snapshot.sql
   60_wlcr.sql
   61_wlcr.sql
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to