mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 17:52:57 +00:00
* feat: add pg and mysql server_address options * feat: start pg and mysql server(standalone) * feat: start pg and mysql in distribute * feat: finally get there, specify postgres sqlness * feat: support mysql sqlness * fix: license * fix: remove unused import * fix: toml * fix: clippy * refactor: BeginProtocolInterceptorFactory to ProtocolInterceptorFactory * fix: sqlness pg connect * fix: clippy * Apply suggestions from code review Co-authored-by: Yingwen <realevenyag@gmail.com> * fix: rustfmt * fix: reconnect pg and mysql when restart * test: add mysql related sqlness * fix: wait for start while restarting * fix: clippy * fix: cargo lock conflict fix: Cargo.lock conflict * fix: usage of '@@tx_isolation' in sqlness * fix: typos * feat: retry with backoff when create client * fix: use millisecond rather than microseconds in backoff --------- Co-authored-by: Yingwen <realevenyag@gmail.com>
136 lines
4.0 KiB
SQL
136 lines
4.0 KiB
SQL
-- should not able to create pg_catalog
|
|
create database pg_catalog;
|
|
|
|
-- make sure all the pg_catalog tables are only visible to postgres
|
|
select * from pg_catalog.pg_class;
|
|
select * from pg_catalog.pg_namespace;
|
|
select * from pg_catalog.pg_type;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select * from pg_catalog.pg_type order by oid;
|
|
|
|
-- \d
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','v','m','S','f','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- \dt
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- make sure oid of namespace keep stable
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT * FROM pg_namespace ORDER BY oid;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
create database my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
create table foo
|
|
(
|
|
ts TIMESTAMP TIME INDEX
|
|
);
|
|
|
|
-- show tables in `my_db`
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace = (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname = 'my_db'
|
|
);
|
|
|
|
-- \dt
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- show tables in `my_db`, `public`
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname = 'my_db' or nspname = 'public'
|
|
)
|
|
order by relname;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname like 'my%'
|
|
);
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relnamespace, relname, relkind
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname <> 'public'
|
|
and nspname <> 'information_schema'
|
|
and nspname <> 'pg_catalog'
|
|
)
|
|
order by relnamespace, relname;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use public;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
drop schema my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use pg_catalog;
|
|
|
|
-- pg_class
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
desc table pg_class;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
desc table pg_namespace;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
drop table my_db.foo;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use public;
|