Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
--
-- one_c_temp_memory_catalog_lifecycle
--
 
SET client_min_messages = warning;
 
CREATE TEMP TABLE tmc_life_saved_oids(
    label text PRIMARY KEY,
    oid_value oid NOT NULL
);
 
SET enable_temp_memory_catalog = off;
 
CREATE TEMP TABLE tmc_life_phys(
    id integer,
    payload integer
);
 
SET enable_temp_memory_catalog = on;
 
ALTER TABLE pg_temp.tmc_life_phys
    ADD COLUMN added integer DEFAULT 11;
ALTER TABLE pg_temp.tmc_life_phys
    ADD CONSTRAINT tmc_life_phys_payload_check CHECK (payload > 0);
 
INSERT INTO pg_temp.tmc_life_phys(id, payload)
SELECT g, g * 10
FROM generate_series(1, 40) AS g;
 
SELECT id, payload, added
FROM pg_temp.tmc_life_phys
WHERE id IN (1, 40)
ORDER BY id;
 
ANALYZE pg_temp.tmc_life_phys;
 
WITH phys_oid AS (
    SELECT 'pg_temp.tmc_life_phys'::regclass AS oid
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = phys_oid.oid) AS pg_class_rows,
    (SELECT count(*) > 0 FROM pg_catalog.pg_attribute WHERE attrelid = phys_oid.oid AND attnum > 0 AND NOT attisdropped) AS pg_attribute_rows_present,
    (SELECT count(*) > 0 FROM pg_catalog.pg_attrdef WHERE adrelid = phys_oid.oid) AS pg_attrdef_rows_present,
    (SELECT count(*) > 0 FROM pg_catalog.pg_constraint WHERE conrelid = phys_oid.oid) AS pg_constraint_rows_present,
    (SELECT count(*) > 0 FROM pg_catalog.pg_statistic WHERE starelid = phys_oid.oid AND staattnum > 0) AS pg_statistic_rows_present
FROM phys_oid;
 
DROP TABLE pg_temp.tmc_life_phys;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_mem(
    id integer,
    payload integer
);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_mem', 'pg_temp.tmc_life_mem'::regclass);
 
SET enable_temp_memory_catalog = off;
 
ALTER TABLE pg_temp.tmc_life_mem
    ADD COLUMN value integer DEFAULT 7;
 
INSERT INTO pg_temp.tmc_life_mem(id, payload)
VALUES (1, 100);
 
SELECT id, payload, value
FROM pg_temp.tmc_life_mem
ORDER BY id;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_attribute WHERE attrelid = mem_oid.oid AND attname = 'value') AS physical_value_attribute_rows,
    (SELECT count(*) FROM pg_catalog.pg_attrdef WHERE adrelid = mem_oid.oid) AS physical_attrdef_rows
FROM mem_oid;
 
ALTER TABLE pg_temp.tmc_life_mem
    ALTER COLUMN value SET DEFAULT 13;
 
INSERT INTO pg_temp.tmc_life_mem(id, payload)
VALUES (2, 200);
 
SELECT id, value
FROM pg_temp.tmc_life_mem
ORDER BY id;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_attrdef WHERE adrelid = mem_oid.oid) AS physical_attrdef_rows_after_set_default
FROM mem_oid;
 
ALTER TABLE pg_temp.tmc_life_mem
    ADD CONSTRAINT tmc_life_mem_value_check CHECK (value > 0);
 
INSERT INTO pg_temp.tmc_life_mem(id, payload, value)
VALUES (3, 300, 17);
 
DO $$
BEGIN
    BEGIN
        INSERT INTO pg_temp.tmc_life_mem(id, payload, value)
        VALUES (4, 400, -1);
        RAISE EXCEPTION 'tmc_life_mem_value_check did not reject invalid input';
    EXCEPTION
        WHEN check_violation THEN
            NULL;
    END;
END;
$$;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_constraint WHERE conrelid = mem_oid.oid) AS physical_constraint_rows_after_check
FROM mem_oid;
 
ALTER TABLE pg_temp.tmc_life_mem
    ADD CONSTRAINT tmc_life_mem_id_unique UNIQUE (id, payload);
 
DO $$
BEGIN
    BEGIN
        INSERT INTO pg_temp.tmc_life_mem(id, payload, value)
        VALUES (1, 100, 13);
        RAISE EXCEPTION 'tmc_life_mem_id_unique did not reject duplicate input';
    EXCEPTION
        WHEN unique_violation THEN
            NULL;
    END;
END;
$$;
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES (
    'tmc_life_mem_idx',
    'pg_temp.tmc_life_mem_id_unique'::regclass::oid
);
 
SELECT to_regclass('pg_temp.tmc_life_mem_id_unique') IS NOT NULL AS mem_unique_visible;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
),
mem_index_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem_idx'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_constraint WHERE conrelid = mem_oid.oid) AS physical_constraint_rows_after_unique,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = mem_index_oid.oid) AS physical_index_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_index WHERE indexrelid = mem_index_oid.oid) AS physical_pg_index_rows,
    (SELECT count(*) FROM pg_catalog.pg_type WHERE typrelid = mem_index_oid.oid) AS physical_index_type_rows
FROM mem_oid, mem_index_oid;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
)
SELECT
    (SELECT count(*)
     FROM pg_catalog.pg_depend
     WHERE classid = 'pg_class'::regclass
       AND objid = mem_oid.oid
       AND objsubid = 3
       AND refclassid = 'pg_type'::regclass) AS physical_value_type_depend_rows
FROM mem_oid;
 
INSERT INTO pg_temp.tmc_life_mem(id, payload, value)
SELECT g, g * 100, g + 20
FROM generate_series(10, 60) AS g;
 
ANALYZE pg_temp.tmc_life_mem;
 
WITH mem_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_mem'
)
SELECT
    (SELECT count(*) FROM pg_temp.tmc_life_mem) AS live_rows,
    (SELECT min(value) FROM pg_temp.tmc_life_mem) AS min_value,
    (SELECT max(value) FROM pg_temp.tmc_life_mem) AS max_value,
    (SELECT count(*) FROM pg_catalog.pg_statistic WHERE starelid = mem_oid.oid AND staattnum > 0) AS physical_pg_statistic_rows
FROM mem_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_parent(
    id integer,
    payload integer
) PARTITION BY RANGE (id);
 
CREATE TEMP TABLE tmc_life_child(
    id integer,
    payload integer
);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES
    ('tmc_life_parent', 'pg_temp.tmc_life_parent'::regclass),
    ('tmc_life_child', 'pg_temp.tmc_life_child'::regclass);
 
SET enable_temp_memory_catalog = off;
 
ALTER TABLE pg_temp.tmc_life_parent
    ATTACH PARTITION pg_temp.tmc_life_child
    FOR VALUES FROM (0) TO (100);
 
INSERT INTO pg_temp.tmc_life_parent(id, payload)
VALUES (5, 500);
 
SELECT id, payload
FROM pg_temp.tmc_life_child;
 
WITH parent_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_parent'
),
child_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_child'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_inherits WHERE inhparent = parent_oid.oid AND inhrelid = child_oid.oid) AS physical_pg_inherits_rows
FROM parent_oid, child_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_rename_old(
    id integer
);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_rename', 'pg_temp.tmc_life_rename_old'::regclass);
 
SET enable_temp_memory_catalog = off;
 
ALTER TABLE pg_temp.tmc_life_rename_old
    RENAME TO tmc_life_rename_new;
 
WITH rename_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_rename'
)
SELECT
    to_regclass('pg_temp.tmc_life_rename_old') IS NULL AS old_name_missing,
    to_regclass('pg_temp.tmc_life_rename_new') IS NOT NULL AS new_name_visible,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = rename_oid.oid) AS physical_pg_class_rows
FROM rename_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_rename_rb(
    id integer
);
 
SET enable_temp_memory_catalog = off;
 
BEGIN;
SAVEPOINT tmc_life_rename_rb_sp;
ALTER TABLE pg_temp.tmc_life_rename_rb
    RENAME TO tmc_life_rename_rb_new;
SELECT
    to_regclass('pg_temp.tmc_life_rename_rb') IS NULL AS rename_rb_old_missing_inside,
    to_regclass('pg_temp.tmc_life_rename_rb_new') IS NOT NULL AS rename_rb_new_visible_inside;
ROLLBACK TO SAVEPOINT tmc_life_rename_rb_sp;
RELEASE SAVEPOINT tmc_life_rename_rb_sp;
COMMIT;
 
SELECT
    to_regclass('pg_temp.tmc_life_rename_rb') IS NOT NULL AS rename_rb_old_visible_after,
    to_regclass('pg_temp.tmc_life_rename_rb_new') IS NULL AS rename_rb_new_missing_after;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_truncate(
    id integer,
    payload text
);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_truncate', 'pg_temp.tmc_life_truncate'::regclass);
 
INSERT INTO pg_temp.tmc_life_truncate(id, payload)
VALUES
    (1, repeat('x', 10000)),
    (2, 'short');
 
SET enable_temp_memory_catalog = off;
 
TRUNCATE TABLE pg_temp.tmc_life_truncate;
 
INSERT INTO pg_temp.tmc_life_truncate(id, payload)
VALUES (3, 'after truncate');
 
WITH truncate_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_truncate'
)
SELECT
    (SELECT count(*) FROM pg_temp.tmc_life_truncate) AS rows_after_truncate,
    to_regclass('pg_temp.tmc_life_truncate') IS NOT NULL AS truncate_table_visible,
    (SELECT payload FROM pg_temp.tmc_life_truncate WHERE id = 3) AS inserted_payload,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = truncate_oid.oid) AS physical_pg_class_rows
FROM truncate_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_reindex(
    id integer,
    payload integer,
    extra integer
);
 
INSERT INTO pg_temp.tmc_life_reindex
SELECT g, g * 5, g * 7
FROM generate_series(1, 25) AS g;
 
CREATE INDEX tmc_life_reindex_idx
ON pg_temp.tmc_life_reindex USING btree (id, payload);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_reindex_idx', 'pg_temp.tmc_life_reindex_idx'::regclass);
 
SET enable_temp_memory_catalog = off;
 
REINDEX INDEX pg_temp.tmc_life_reindex_idx;
 
WITH reindex_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_reindex_idx'
)
SELECT
    to_regclass('pg_temp.tmc_life_reindex_idx') IS NOT NULL AS reindex_visible,
    (SELECT extra FROM pg_temp.tmc_life_reindex WHERE id = 7 AND payload = 35) AS indexed_lookup_extra,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = reindex_oid.oid) AS physical_pg_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_index WHERE indexrelid = reindex_oid.oid) AS physical_pg_index_rows,
    (SELECT count(*) FROM pg_catalog.pg_type WHERE typrelid = reindex_oid.oid) AS physical_pg_type_rows
FROM reindex_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_drop(
    id integer,
    payload integer DEFAULT 17,
    CONSTRAINT tmc_life_drop_payload_check CHECK (payload > 0),
    CONSTRAINT tmc_life_drop_id_payload_unique UNIQUE (id, payload)
);
 
INSERT INTO pg_temp.tmc_life_drop(id)
VALUES (1);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_drop', 'pg_temp.tmc_life_drop'::regclass);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES (
    'tmc_life_drop_idx',
    'pg_temp.tmc_life_drop_id_payload_unique'::regclass::oid
);
 
SET enable_temp_memory_catalog = off;
 
DROP TABLE pg_temp.tmc_life_drop;
 
WITH drop_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_drop'
),
drop_index_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_drop_idx'
)
SELECT
    to_regclass('pg_temp.tmc_life_drop') IS NULL AS drop_table_missing,
    to_regclass('pg_temp.tmc_life_drop_id_payload_unique') IS NULL AS drop_index_missing,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = drop_oid.oid) AS residual_pg_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_attribute WHERE attrelid = drop_oid.oid) AS residual_pg_attribute_rows,
    (SELECT count(*) FROM pg_catalog.pg_attrdef WHERE adrelid = drop_oid.oid) AS residual_pg_attrdef_rows,
    (SELECT count(*) FROM pg_catalog.pg_constraint WHERE conrelid = drop_oid.oid) AS residual_pg_constraint_rows,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = drop_index_oid.oid) AS residual_index_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_index WHERE indexrelid = drop_index_oid.oid) AS residual_pg_index_rows,
    (SELECT count(*) FROM pg_catalog.pg_type WHERE typrelid = drop_index_oid.oid) AS residual_pg_type_rows
FROM drop_oid, drop_index_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_drop_rb(
    id integer,
    payload integer DEFAULT 23,
    CONSTRAINT tmc_life_drop_rb_payload_check CHECK (payload > 0),
    CONSTRAINT tmc_life_drop_rb_id_payload_unique UNIQUE (id, payload)
);
 
INSERT INTO pg_temp.tmc_life_drop_rb(id)
VALUES (1);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_drop_rb', 'pg_temp.tmc_life_drop_rb'::regclass);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES (
    'tmc_life_drop_rb_idx',
    'pg_temp.tmc_life_drop_rb_id_payload_unique'::regclass::oid
);
 
SET enable_temp_memory_catalog = off;
 
BEGIN;
SAVEPOINT tmc_life_drop_rb_sp;
DROP TABLE pg_temp.tmc_life_drop_rb;
SELECT to_regclass('pg_temp.tmc_life_drop_rb') IS NULL AS drop_rb_missing_inside;
ROLLBACK TO SAVEPOINT tmc_life_drop_rb_sp;
RELEASE SAVEPOINT tmc_life_drop_rb_sp;
COMMIT;
 
DO $$
BEGIN
    BEGIN
        INSERT INTO pg_temp.tmc_life_drop_rb(id, payload)
        VALUES (2, 0);
        RAISE EXCEPTION 'tmc_life_drop_rb_payload_check did not reject invalid input';
    EXCEPTION
        WHEN check_violation THEN
            NULL;
    END;
 
    BEGIN
        INSERT INTO pg_temp.tmc_life_drop_rb(id, payload)
        VALUES (1, 23);
        RAISE EXCEPTION 'tmc_life_drop_rb_id_payload_unique did not reject duplicate input';
    EXCEPTION
        WHEN unique_violation THEN
            NULL;
    END;
END;
$$;
 
WITH drop_rb_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_drop_rb'
),
drop_rb_index_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_drop_rb_idx'
)
SELECT
    to_regclass('pg_temp.tmc_life_drop_rb') IS NOT NULL AS drop_rb_visible_after,
    (SELECT id FROM pg_temp.tmc_life_drop_rb WHERE id = 1) AS preserved_id,
    (SELECT payload FROM pg_temp.tmc_life_drop_rb WHERE id = 1) AS preserved_payload,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = drop_rb_oid.oid) AS residual_pg_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_attrdef WHERE adrelid = drop_rb_oid.oid) AS residual_pg_attrdef_rows,
    (SELECT count(*) FROM pg_catalog.pg_constraint WHERE conrelid = drop_rb_oid.oid) AS residual_pg_constraint_rows,
    (SELECT count(*) FROM pg_catalog.pg_class WHERE oid = drop_rb_index_oid.oid) AS residual_index_class_rows,
    (SELECT count(*) FROM pg_catalog.pg_index WHERE indexrelid = drop_rb_index_oid.oid) AS residual_pg_index_rows
FROM drop_rb_oid, drop_rb_index_oid;
 
SET enable_temp_memory_catalog = on;
 
CREATE TEMP TABLE tmc_life_alter_rb(
    id integer,
    payload integer
);
 
INSERT INTO pg_temp.tmc_life_saved_oids(label, oid_value)
VALUES ('tmc_life_alter_rb', 'pg_temp.tmc_life_alter_rb'::regclass);
 
INSERT INTO pg_temp.tmc_life_alter_rb(id, payload)
VALUES (1, 10);
 
SET enable_temp_memory_catalog = off;
 
BEGIN;
SAVEPOINT tmc_life_alter_rb_sp;
ALTER TABLE pg_temp.tmc_life_alter_rb
    ADD COLUMN added integer DEFAULT 31;
ALTER TABLE pg_temp.tmc_life_alter_rb
    ADD CONSTRAINT tmc_life_alter_rb_added_check CHECK (added > 0);
INSERT INTO pg_temp.tmc_life_alter_rb(id, payload)
VALUES (2, 20);
SELECT id, payload, added
FROM pg_temp.tmc_life_alter_rb
ORDER BY id;
ROLLBACK TO SAVEPOINT tmc_life_alter_rb_sp;
RELEASE SAVEPOINT tmc_life_alter_rb_sp;
COMMIT;
 
DO $$
BEGIN
    BEGIN
        PERFORM added FROM pg_temp.tmc_life_alter_rb LIMIT 1;
        RAISE EXCEPTION 'rolled back column added is still visible';
    EXCEPTION
        WHEN undefined_column THEN
            NULL;
    END;
END;
$$;
 
WITH alter_rb_oid AS (
    SELECT oid_value AS oid
    FROM pg_temp.tmc_life_saved_oids
    WHERE label = 'tmc_life_alter_rb'
)
SELECT
    (SELECT count(*) FROM pg_catalog.pg_attribute WHERE attrelid = alter_rb_oid.oid AND attname = 'added') AS residual_added_attribute_rows,
    (SELECT count(*) FROM pg_catalog.pg_attrdef WHERE adrelid = alter_rb_oid.oid) AS residual_pg_attrdef_rows,
    (SELECT count(*) FROM pg_catalog.pg_constraint WHERE conrelid = alter_rb_oid.oid AND conname = 'tmc_life_alter_rb_added_check') AS residual_pg_constraint_rows
FROM alter_rb_oid;
 
SELECT id, payload
FROM pg_temp.tmc_life_alter_rb
ORDER BY id;
 
DROP TABLE IF EXISTS pg_temp.tmc_life_alter_rb;
DROP TABLE IF EXISTS pg_temp.tmc_life_drop_rb;
DROP TABLE IF EXISTS pg_temp.tmc_life_reindex;
DROP TABLE IF EXISTS pg_temp.tmc_life_truncate;
DROP TABLE IF EXISTS pg_temp.tmc_life_rename_rb;
DROP TABLE IF EXISTS pg_temp.tmc_life_rename_new;
DROP TABLE IF EXISTS pg_temp.tmc_life_child;
DROP TABLE IF EXISTS pg_temp.tmc_life_parent;
DROP TABLE IF EXISTS pg_temp.tmc_life_mem;
DROP TABLE IF EXISTS pg_temp.tmc_life_saved_oids;
 
RESET enable_temp_memory_catalog;