Skip to content

Commit 60eb192

Browse files
committed
Drop dead code, replace COPY-with-lint-suppression with a plain INSERT
- sql/object_reference.sql: the commented-out CREATE TEMP TABLE ... AS alternative in the ddl_capture exception handler was dead weight, not a real alternative worth preserving in a comment. - test/helpers/object_table.sql: the disable-block was working around the linter scanning raw COPY payload text for type-name substrings. A quoted string literal isn't scanned at all, so a plain multi-row INSERT needs no suppression -- same data, properly quoted.
1 parent 161e4ab commit 60eb192

2 files changed

Lines changed: 16 additions & 23 deletions

File tree

sql/object_reference.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,11 +1258,6 @@ BEGIN
12581258
RETURN c_next_level;
12591259

12601260
EXCEPTION WHEN undefined_table THEN
1261-
/* EXCLUDED CODE
1262-
CREATE TEMP TABLE __object_reference__ddl_capture AS
1263-
SELECT c_next_level, capture__start.object_group_id
1264-
;
1265-
*/
12661261
CREATE TEMP TABLE __object_reference__ddl_capture(
12671262
capture_level int PRIMARY KEY
12681263
, object_group_id INT NOT NULL -- temp tables can't reference permanent ones

test/helpers/object_table.sql

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,22 @@ INSERT INTO test_prereq VALUES
143143
, ($$CREATE FUNCTION "test type out"("test type") RETURNS cstring LANGUAGE 'internal' IMMUTABLE AS 'int2in'$$)
144144
;
145145

146-
-- \N is null character
147-
-- sql-lint:disable-block prefer-short-type: secondary column mirrors pg_catalog's own type display name (format_type), not a style choice
148-
COPY test_object(object_type, object_name, secondary, create_command, drop_command) FROM STDIN (DELIMITER '|');
149-
table|test table||%("test column" int)|
150-
index|test table test index||%ON "test table"("test column")|
151-
sequence|test sequence|||
152-
view|test view||%AS SELECT * FROM "test table"|
153-
materialized view|test materialized view||%AS SELECT * FROM "test table"|
154-
table column|test table|second test column|ALTER TABLE "test table" ADD COLUMN "second test column" int|ALTER TABLE "test table" DROP COLUMN "second test column"
155-
domain constraint|test domain|test domain constraint|ALTER DOMAIN "test domain" ADD CONSTRAINT "test domain constraint" CHECK(true)|ALTER DOMAIN "test domain" DROP CONSTRAINT "test domain constraint"
156-
table constraint|test table|test table constraint|ALTER TABLE "test table" ADD CONSTRAINT "test table constraint" CHECK(true)|ALTER TABLE "test table" DROP CONSTRAINT "test table constraint"
157-
function|test function|"test column" int DEFAULT 0|CREATE FUNCTION "test function"("test column" int DEFAULT 0) RETURNS int LANGUAGE sql AS 'SELECT $1'|DROP FUNCTION "test function"(int)
158-
type|test type||CREATE TYPE "test type" (INPUT = "test type in", OUTPUT = "test type out")|DROP TYPE "test type" CASCADE; -- Need to cascade due to functions
159-
cast|test type|integer|CREATE CAST ("test type" AS int4) WITH INOUT|DROP CAST ("test type" AS int4)
160-
default value|test table|test column|ALTER TABLE "test table" ALTER "test column" SET DEFAULT 0|ALTER TABLE "test table" ALTER "test column" DROP DEFAULT
161-
trigger|test table|test trigger|CREATE TRIGGER "test trigger" AFTER INSERT ON "test table" FOR EACH ROW EXECUTE PROCEDURE tg_null()|DROP TRIGGER "test trigger" ON "test table"
162-
\.
163-
-- sql-lint:enable-block
146+
INSERT INTO test_object(object_type, object_name, secondary, create_command, drop_command) VALUES
147+
('table', 'test table', '', '%("test column" int)', '')
148+
, ('index', 'test table test index', '', '%ON "test table"("test column")', '')
149+
, ('sequence', 'test sequence', '', '', '')
150+
, ('view', 'test view', '', '%AS SELECT * FROM "test table"', '')
151+
, ('materialized view', 'test materialized view', '', '%AS SELECT * FROM "test table"', '')
152+
, ('table column', 'test table', 'second test column', 'ALTER TABLE "test table" ADD COLUMN "second test column" int', 'ALTER TABLE "test table" DROP COLUMN "second test column"')
153+
, ('domain constraint', 'test domain', 'test domain constraint', 'ALTER DOMAIN "test domain" ADD CONSTRAINT "test domain constraint" CHECK(true)', 'ALTER DOMAIN "test domain" DROP CONSTRAINT "test domain constraint"')
154+
, ('table constraint', 'test table', 'test table constraint', 'ALTER TABLE "test table" ADD CONSTRAINT "test table constraint" CHECK(true)', 'ALTER TABLE "test table" DROP CONSTRAINT "test table constraint"')
155+
, ('function', 'test function', '"test column" int DEFAULT 0', 'CREATE FUNCTION "test function"("test column" int DEFAULT 0) RETURNS int LANGUAGE sql AS ''SELECT $1''', 'DROP FUNCTION "test function"(int)')
156+
, ('type', 'test type', '', 'CREATE TYPE "test type" (INPUT = "test type in", OUTPUT = "test type out")', 'DROP TYPE "test type" CASCADE; -- Need to cascade due to functions')
157+
-- secondary mirrors pg_catalog's own type display name (format_type() of int4), not a style choice -- not "int" per prefer-short-type
158+
, ('cast', 'test type', 'integer', 'CREATE CAST ("test type" AS int4) WITH INOUT', 'DROP CAST ("test type" AS int4)')
159+
, ('default value', 'test table', 'test column', 'ALTER TABLE "test table" ALTER "test column" SET DEFAULT 0', 'ALTER TABLE "test table" ALTER "test column" DROP DEFAULT')
160+
, ('trigger', 'test table', 'test trigger', 'CREATE TRIGGER "test trigger" AFTER INSERT ON "test table" FOR EACH ROW EXECUTE PROCEDURE tg_null()', 'DROP TRIGGER "test trigger" ON "test table"')
161+
;
164162

165163
/* EXCLUDED CODE: Not supported
166164
composite type|test complex type||CREATE TYPE "test complex type" AS(r real, i real)|DROP TYPE "test complex type"

0 commit comments

Comments
 (0)