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
|
# name: test/sql/catalog/comment_on_column.test
# description: Test COMMENT ON COLUMN
# group: [catalog]
load __TEST_DIR__/comment_on_column.db
statement ok
CREATE TABLE test_table as SELECT 1 as test_table_column
### Comment on column from table
query I
select comment from duckdb_columns() where column_name='test_table_column';
----
NULL
statement ok
COMMENT ON COLUMN test_table.test_table_column IS 'very gezellige column'
query I
select comment from duckdb_columns() where column_name='test_table_column';
----
very gezellige column
restart
query I
select comment from duckdb_columns() where column_name='test_table_column';
----
very gezellige column
statement ok
CREATE VIEW test_view AS SELECT test_table_column as test_view_column FROM test_table;
### Comment on column from table
query I
select comment from duckdb_columns() where column_name='test_view_column';
----
NULL
statement ok
COMMENT ON COLUMN test_view.test_view_column IS 'very gezellige view column'
query I
select comment from duckdb_columns() where column_name='test_view_column';
----
very gezellige view column
restart
query I
select comment from duckdb_columns() where column_name='test_view_column';
----
very gezellige view column
query IIII
SELECT database_name, table_name, column_name, comment FROM duckdb_columns() where internal is false
----
comment_on_column test_table test_table_column very gezellige column
comment_on_column test_view test_view_column very gezellige view column
# check some erroneous inputs
statement error
COMMENT ON COLUMN bla.bloe.blie.blo IS NULL
----
Catalog "bla" does not exist!
statement error
COMMENT ON COLUMN blie.blo IS NULL
----
Table with name blie does not exist!
statement error
COMMENT ON COLUMN test_view.test_table_column IS NULL
----
View "test_view" does not have a column with name "test_table_column"
statement error
COMMENT ON COLUMN test_table.test_view_column IS NULL
----
Table "test_table" does not have a column with name "test_view_column"
# test that COMMENT ON COLUMN preserves temporary flag
statement ok
CREATE TEMPORARY TABLE temp_comment_test(x INTEGER)
query TTI
SELECT table_name, database_name, temporary FROM duckdb_tables() WHERE table_name='temp_comment_test'
----
temp_comment_test temp true
statement ok
COMMENT ON COLUMN temp_comment_test.x IS 'test comment'
query TTI
SELECT table_name, database_name, temporary FROM duckdb_tables() WHERE table_name='temp_comment_test'
----
temp_comment_test temp true
|