1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
# name: test/sql/catalog/comment_on_pg_description.test
# description: Test the pg_description function for comment on
# group: [catalog]
statement ok
CREATE TABLE test AS SELECT 1 as a;
statement ok
COMMENT ON TABLE test IS 'comment-1'
statement ok
COMMENT ON COLUMN test.a IS 'comment-2'
statement ok
CREATE VIEW test_view AS FROM test;
statement ok
COMMENT ON COLUMN test_view.a IS 'comment-2.5'
statement ok
CREATE INDEX test_index ON test(a)
statement ok
COMMENT ON VIEW test_view IS 'comment-3'
statement ok
COMMENT ON INDEX test_index IS 'comment-4'
statement ok
CREATE SEQUENCE seq
statement ok
COMMENT ON SEQUENCE seq IS 'comment-5'
statement ok
CREATE TYPE test_type AS int32;
statement ok
COMMENT ON TYPE test_type IS 'comment-6'
statement ok
CREATE MACRO test_table_macro(a,b) as TABLE select a,b;
statement ok
CREATE FUNCTION test_function(a, b) AS a + b
statement ok
COMMENT ON MACRO TABLE test_table_macro IS 'comment-7'
statement ok
COMMENT ON MACRO test_function IS 'comment-8'
# Confirm that pg_description matches
query II
SELECT ddb.comment, pg.description
FROM duckdb_tables AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.table_oid
WHERE pg.objsubid=0 AND ddb.table_name='test'
----
comment-1 comment-1
query II
SELECT ddb.comment, pg.description
FROM duckdb_columns AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.table_oid
WHERE pg.objsubid=1 AND ddb.table_name='test'
----
comment-2 comment-2
query II
SELECT ddb.comment, pg.description
FROM duckdb_columns AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.table_oid
WHERE pg.objsubid=1 AND ddb.table_name='test_view'
----
comment-2.5 comment-2.5
query II
SELECT ddb.comment, pg.description
FROM duckdb_views AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.view_oid
WHERE pg.objsubid=0 AND ddb.view_name='test_view'
----
comment-3 comment-3
query II
SELECT ddb.comment, pg.description
FROM duckdb_indexes AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.index_oid
WHERE ddb.index_name='test_index'
----
comment-4 comment-4
query II
SELECT ddb.comment, pg.description
FROM duckdb_sequences() AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.sequence_oid
WHERE ddb.sequence_name='seq'
----
comment-5 comment-5
query II
SELECT ddb.comment, pg.description
FROM duckdb_types() AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.type_oid
WHERE ddb.type_name='test_type'
----
comment-6 comment-6
query II
SELECT ddb.comment, pg.description
FROM duckdb_functions() AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.function_oid
WHERE ddb.function_name='test_table_macro'
----
comment-7 comment-7
query II
SELECT ddb.comment, pg.description
FROM duckdb_functions() AS ddb
LEFT JOIN pg_description AS pg
ON pg.classoid=ddb.database_oid AND pg.objoid=ddb.function_oid
WHERE ddb.function_name='test_function'
----
comment-8 comment-8
|