github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/privileges_comments (about)

     1  # Disable automatic stats to avoid flakiness.
     2  statement ok
     3  SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false
     4  
     5  subtest regression45707
     6  
     7  user root
     8  
     9  statement ok
    10  CREATE DATABASE d45707; CREATE TABLE d45707.t45707(x INT);
    11    GRANT SELECT ON DATABASE d45707 TO testuser;
    12    GRANT SELECT ON d45707.t45707 TO testuser
    13  
    14  statement ok
    15  COMMENT ON DATABASE d45707 IS 'd45707';
    16  COMMENT ON TABLE d45707.t45707 IS 't45707';
    17  COMMENT ON COLUMN d45707.t45707.x IS 'x45707';
    18  COMMENT ON INDEX d45707.t45707@primary IS 'p45707'
    19  
    20  user testuser
    21  
    22  statement ok
    23  SET DATABASE = d45707
    24  
    25  # Verify the user cannot modify the comments
    26  
    27  statement error user testuser does not have CREATE privilege on database d45707
    28  COMMENT ON DATABASE d45707 IS 'd45707'
    29  
    30  statement error user testuser does not have CREATE privilege on relation t45707
    31  COMMENT ON TABLE d45707.t45707 IS 't45707'
    32  
    33  statement error user testuser does not have CREATE privilege on relation t45707
    34  COMMENT ON COLUMN d45707.t45707.x IS 'x45707'
    35  
    36  statement error user testuser does not have CREATE privilege on relation t45707
    37  COMMENT ON INDEX d45707.t45707@primary IS 'p45707'
    38  
    39  # Verify that the user can view the comments
    40  
    41  query T
    42  SELECT shobj_description(oid, 'pg_database')
    43    FROM pg_database
    44   WHERE datname = 'd45707'
    45  ----
    46  d45707
    47  
    48  query T
    49  SELECT col_description(attrelid, attnum)
    50    FROM pg_attribute
    51   WHERE attrelid = 't45707'::regclass AND attname = 'x'
    52  ----
    53  x45707
    54  
    55  query T
    56  SELECT obj_description('t45707'::REGCLASS)
    57  ----
    58  t45707
    59  
    60  query T
    61  SELECT obj_description(indexrelid)
    62    FROM pg_index
    63   WHERE indrelid = 't45707'::REGCLASS
    64     AND indisprimary
    65  ----
    66  p45707
    67  
    68  # Verify that the user can modify the comments.
    69  
    70  user root
    71  
    72  statement ok
    73  GRANT ALL ON DATABASE d45707 TO testuser;
    74    GRANT ALL ON TABLE d45707.t45707 TO testuser
    75  
    76  user testuser
    77  
    78  statement ok
    79  COMMENT ON DATABASE d45707 IS 'd45707_2';
    80  COMMENT ON TABLE d45707.t45707 IS 't45707_2';
    81  COMMENT ON COLUMN d45707.t45707.x IS 'x45707_2';
    82  COMMENT ON INDEX d45707.t45707@primary IS 'p45707_2'