-- $Id: TestSelfColGrant.txt 610 2008-12-22 15:54:18Z unsaved $
-- Tests column-specific grants

-- These two users are for sanity tests
/*u0*/CREATE USER privd identified by "privd";
/*u0*/CREATE USER unprivd identified by "unprivd";

/*u0*/CREATE USER u1 identified by "u1";
/*u0*/GRANT CHANGE_AUTHORIZATION TO u1;
/*u0*/GRANT CHANGE_AUTHORIZATION TO privd;
/*u0*/GRANT CHANGE_AUTHORIZATION TO unprivd;
/*u0*/CREATE TABLE multicol (openc int, closedc int, limitedc int);
/*u1*/INSERT INTO multicol values (1, 2, 3);
/*c1*/SELECT * from multicol;
/*u0*/GRANT ALL ON multicol TO privd;
/*u0*/GRANT SELECT(limitedc) ON multicol TO u1;
/*u0*/GRANT SELECT(openc) ON multicol TO public;
/*u0*/GRANT INSERT(openc) ON multicol TO public;
/*u0*/GRANT UPDATE(openc) ON multicol TO public;


-- Test col-specific SELECTs
/*u0*/CONNECT USER u1 identified by "u1";
/*c1*/SELECT openc from multicol;
/*c1*/SELECT limitedc from multicol;
/*e*/SELECT closedc from multicol;
/*e*/UPDATE multicol set limitedc = 4 where openc = 1;

/*u0*/CONNECT USER privd identified by "privd";
/*c1*/SELECT openc from multicol;
/*c1*/SELECT limitedc from multicol;
/*c1*/SELECT closedc from multicol;
/*u1*/UPDATE multicol set limitedc = 5 where openc = 1;
/*u0*/CONNECT USER unprivd identified by "unprivd";
/*e*/SELECT limitedc from multicol;
/*e*/SELECT closedc from multicol;
/*e*/UPDATE multicol set limitedc = 6 where openc = 1;

-- Test col-specific UPDATEs
/*u0*/CONNECT USER u1 identified by "u1";
/*c1*/SELECT openc from multicol;
/*e*/UPDATE multicol set limitedc = 7 where openc = 1;
/*u0*/CONNECT USER SA identified by "";
/*u0*/GRANT update(limitedc) ON multicol TO u1;
/*u0*/CONNECT USER u1 identified by "u1";
/*u1*/UPDATE multicol set limitedc = 7 where openc = 1;

-- Test col-specific INSERTs
/*u0*/CONNECT USER u1 identified by "u1";
/*e*/INSERT INTO multicol(limitedc) values(10);
/*u0*/CONNECT USER SA identified by "";
/*u0*/GRANT insert(limitedc) ON multicol TO u1;
/*u0*/CONNECT USER privd identified by "privd";
/*u1*/INSERT INTO multicol(limitedc) values(11);
/*u0*/CONNECT USER unprivd identified by "unprivd";
/*e*/INSERT INTO multicol(limitedc) values(12);
/*u0*/CONNECT USER u1 identified by "u1";
/*u1*/INSERT INTO multicol(limitedc) values(13);

/*u0*/CONNECT USER SA identified by "";
/*u0*/DROP USER u1;
/*u0*/DROP USER privd;
/*u0*/DROP USER unprivd;
/*u0*/DROP TABLE multicol;
/*u0*/SHUTDOWN;
