--
|
-- one_c_temp_memory_catalog_sequence
|
--
|
SET client_min_messages = warning;
|
SET enable_temp_memory_catalog = off;
|
CREATE TEMP SEQUENCE tmc_seq_phys
|
START WITH 10
|
INCREMENT BY 3;
|
WITH seq_oid AS (
|
SELECT 'pg_temp.tmc_seq_phys'::regclass AS oid
|
)
|
SELECT
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) > 0
|
FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows_present,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows,
|
(SELECT count(*) > 0
|
FROM pg_catalog.pg_depend
|
WHERE classid = 'pg_catalog.pg_class'::regclass
|
AND objid = seq_oid.oid) AS pg_depend_rows_present
|
FROM seq_oid;
|
pg_class_rows | pg_attribute_rows_present | pg_sequence_rows | pg_depend_rows_present
|
---------------+---------------------------+------------------+------------------------
|
1 | t | 1 | t
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_phys') AS phys_nextval_1;
|
phys_nextval_1
|
----------------
|
10
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_phys') AS phys_nextval_2;
|
phys_nextval_2
|
----------------
|
13
|
(1 row)
|
|
SET enable_temp_memory_catalog = on;
|
ALTER SEQUENCE pg_temp.tmc_seq_phys
|
RESTART WITH 20
|
INCREMENT BY 5;
|
SELECT nextval('pg_temp.tmc_seq_phys') AS phys_nextval_3;
|
phys_nextval_3
|
----------------
|
20
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_phys') AS phys_nextval_4;
|
phys_nextval_4
|
----------------
|
25
|
(1 row)
|
|
WITH seq_oid AS (
|
SELECT 'pg_temp.tmc_seq_phys'::regclass AS oid
|
)
|
SELECT
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) > 0
|
FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows_present,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows
|
FROM seq_oid;
|
pg_class_rows | pg_attribute_rows_present | pg_sequence_rows
|
---------------+---------------------------+------------------
|
1 | t | 1
|
(1 row)
|
|
DROP SEQUENCE pg_temp.tmc_seq_phys;
|
SET enable_temp_memory_catalog = on;
|
CREATE TEMP SEQUENCE tmc_seq_mem
|
START WITH 2
|
INCREMENT BY 4;
|
WITH seq_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_mem') AS oid
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_mem') IS NOT NULL AS mem_seq_visible,
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows,
|
(SELECT count(*) FROM pg_catalog.pg_depend
|
WHERE classid = 'pg_catalog.pg_class'::regclass
|
AND objid = seq_oid.oid) AS pg_depend_rows
|
FROM seq_oid;
|
mem_seq_visible | pg_class_rows | pg_attribute_rows | pg_sequence_rows | pg_depend_rows
|
-----------------+---------------+-------------------+------------------+----------------
|
t | 0 | 0 | 0 | 0
|
(1 row)
|
|
SET enable_temp_memory_catalog = off;
|
SELECT nextval('pg_temp.tmc_seq_mem') AS mem_nextval_1;
|
mem_nextval_1
|
---------------
|
2
|
(1 row)
|
|
SELECT currval('pg_temp.tmc_seq_mem') AS mem_currval_1;
|
mem_currval_1
|
---------------
|
2
|
(1 row)
|
|
SELECT setval('pg_temp.tmc_seq_mem', 50, false) AS mem_setval;
|
mem_setval
|
------------
|
50
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_mem') AS mem_nextval_2;
|
mem_nextval_2
|
---------------
|
50
|
(1 row)
|
|
ALTER SEQUENCE pg_temp.tmc_seq_mem
|
RESTART WITH 100
|
INCREMENT BY 7;
|
SELECT nextval('pg_temp.tmc_seq_mem') AS mem_nextval_3;
|
mem_nextval_3
|
---------------
|
100
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_mem') AS mem_nextval_4;
|
mem_nextval_4
|
---------------
|
107
|
(1 row)
|
|
WITH seq_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_mem') AS oid
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_mem') IS NOT NULL AS mem_seq_visible,
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows
|
FROM seq_oid;
|
mem_seq_visible | pg_class_rows | pg_attribute_rows | pg_sequence_rows
|
-----------------+---------------+-------------------+------------------
|
t | 0 | 0 | 0
|
(1 row)
|
|
SET enable_temp_memory_catalog = on;
|
CREATE TEMP TABLE tmc_seq_owner(id integer);
|
CREATE TEMP SEQUENCE tmc_seq_owned
|
START WITH 1
|
INCREMENT BY 1
|
OWNED BY tmc_seq_owner.id;
|
SET enable_temp_memory_catalog = off;
|
WITH owned_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_owned') AS oid
|
),
|
owner_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_owner') AS oid
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_owned') IS NOT NULL AS owned_seq_visible,
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = owned_oid.oid) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid = owned_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = owned_oid.oid) AS pg_sequence_rows,
|
(SELECT count(*) FROM pg_catalog.pg_depend
|
WHERE classid = 'pg_catalog.pg_class'::regclass
|
AND objid = owned_oid.oid) AS pg_depend_rows,
|
(SELECT count(*) FROM pg_catalog.pg_depend
|
WHERE classid = 'pg_catalog.pg_class'::regclass
|
AND objid = owned_oid.oid
|
AND refclassid = 'pg_catalog.pg_class'::regclass
|
AND refobjid = owner_oid.oid
|
AND refobjsubid = 1) AS owned_by_depend_rows
|
FROM owned_oid, owner_oid;
|
owned_seq_visible | pg_class_rows | pg_attribute_rows | pg_sequence_rows | pg_depend_rows | owned_by_depend_rows
|
-------------------+---------------+-------------------+------------------+----------------+----------------------
|
t | 0 | 0 | 0 | 0 | 0
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_owned') AS owned_nextval_1;
|
owned_nextval_1
|
-----------------
|
1
|
(1 row)
|
|
DROP TABLE pg_temp.tmc_seq_owner;
|
SELECT to_regclass('pg_temp.tmc_seq_owned') IS NULL AS owned_seq_missing_after_drop;
|
owned_seq_missing_after_drop
|
------------------------------
|
t
|
(1 row)
|
|
SET enable_temp_memory_catalog = on;
|
BEGIN;
|
SAVEPOINT tmc_seq_create_s;
|
CREATE TEMP SEQUENCE tmc_seq_create_rb
|
START WITH 30
|
INCREMENT BY 2;
|
SELECT to_regclass('pg_temp.tmc_seq_create_rb') IS NOT NULL AS create_rb_visible_inside;
|
create_rb_visible_inside
|
--------------------------
|
t
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_create_rb') AS create_rb_nextval_inside;
|
create_rb_nextval_inside
|
--------------------------
|
30
|
(1 row)
|
|
ROLLBACK TO SAVEPOINT tmc_seq_create_s;
|
RELEASE SAVEPOINT tmc_seq_create_s;
|
COMMIT;
|
WITH phys AS (
|
SELECT oid
|
FROM pg_catalog.pg_class
|
WHERE relnamespace = pg_my_temp_schema()
|
AND relname = 'tmc_seq_create_rb'
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_create_rb') IS NULL AS create_rb_missing_after,
|
(SELECT count(*) FROM phys) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid IN (SELECT oid FROM phys)
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence
|
WHERE seqrelid IN (SELECT oid FROM phys)) AS pg_sequence_rows;
|
create_rb_missing_after | pg_class_rows | pg_attribute_rows | pg_sequence_rows
|
-------------------------+---------------+-------------------+------------------
|
t | 0 | 0 | 0
|
(1 row)
|
|
SET enable_temp_memory_catalog = on;
|
CREATE TEMP SEQUENCE tmc_seq_drop_rb
|
START WITH 300
|
INCREMENT BY 2;
|
SET enable_temp_memory_catalog = off;
|
BEGIN;
|
SAVEPOINT tmc_seq_drop_s;
|
DROP SEQUENCE pg_temp.tmc_seq_drop_rb;
|
SELECT to_regclass('pg_temp.tmc_seq_drop_rb') IS NULL AS drop_rb_missing_inside;
|
drop_rb_missing_inside
|
------------------------
|
t
|
(1 row)
|
|
ROLLBACK TO SAVEPOINT tmc_seq_drop_s;
|
RELEASE SAVEPOINT tmc_seq_drop_s;
|
COMMIT;
|
WITH seq_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_drop_rb') AS oid
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_drop_rb') IS NOT NULL AS drop_rb_visible_after,
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows
|
FROM seq_oid;
|
drop_rb_visible_after | pg_class_rows | pg_attribute_rows | pg_sequence_rows
|
-----------------------+---------------+-------------------+------------------
|
t | 0 | 0 | 0
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_drop_rb') AS drop_rb_nextval_after;
|
drop_rb_nextval_after
|
-----------------------
|
300
|
(1 row)
|
|
SET enable_temp_memory_catalog = on;
|
CREATE TEMP SEQUENCE tmc_seq_alter_rb
|
START WITH 400
|
INCREMENT BY 3;
|
SET enable_temp_memory_catalog = off;
|
BEGIN;
|
SAVEPOINT tmc_seq_alter_s;
|
ALTER SEQUENCE pg_temp.tmc_seq_alter_rb
|
INCREMENT BY 11;
|
ROLLBACK TO SAVEPOINT tmc_seq_alter_s;
|
RELEASE SAVEPOINT tmc_seq_alter_s;
|
COMMIT;
|
SELECT nextval('pg_temp.tmc_seq_alter_rb') AS alter_rb_nextval_1;
|
alter_rb_nextval_1
|
--------------------
|
400
|
(1 row)
|
|
SELECT nextval('pg_temp.tmc_seq_alter_rb') AS alter_rb_nextval_2;
|
alter_rb_nextval_2
|
--------------------
|
403
|
(1 row)
|
|
WITH seq_oid AS (
|
SELECT to_regclass('pg_temp.tmc_seq_alter_rb') AS oid
|
)
|
SELECT
|
to_regclass('pg_temp.tmc_seq_alter_rb') IS NOT NULL AS alter_rb_visible_after,
|
(SELECT count(*) FROM pg_catalog.pg_class WHERE oid = seq_oid.oid) AS pg_class_rows,
|
(SELECT count(*) FROM pg_catalog.pg_attribute
|
WHERE attrelid = seq_oid.oid
|
AND attnum > 0
|
AND NOT attisdropped) AS pg_attribute_rows,
|
(SELECT count(*) FROM pg_catalog.pg_sequence WHERE seqrelid = seq_oid.oid) AS pg_sequence_rows
|
FROM seq_oid;
|
alter_rb_visible_after | pg_class_rows | pg_attribute_rows | pg_sequence_rows
|
------------------------+---------------+-------------------+------------------
|
t | 0 | 0 | 0
|
(1 row)
|
|
DROP SEQUENCE IF EXISTS pg_temp.tmc_seq_mem;
|
DROP SEQUENCE IF EXISTS pg_temp.tmc_seq_drop_rb;
|
DROP SEQUENCE IF EXISTS pg_temp.tmc_seq_alter_rb;
|
RESET enable_temp_memory_catalog;
|