Skip to content

Commit 01954e5

Browse files
RekGRpthclaude
andcommitted
fix: task_insert() uses INSERT ... AS alias unsupported before 9.5
INSERT INTO tablename AS alias was added in PostgreSQL 9.5 alongside ON CONFLICT; on 9.4 it's a plain syntax error, so every repeat-chain insert failed there ("syntax error at or near AS"), crashing the owning pg_work worker and looping it through the 60s bgw_restart_time throttle - confirmed via debug log from CI run 30324794582's REL9_4_STABLE-test job. The "AS t" alias on the INSERT target was never needed (only RETURNING t.id used it); drop it and return RETURNING id instead, which is valid on every supported version. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent df14841 commit 01954e5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

task.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ static void task_insert(const Task *t) {
100100
if (!columns) return;
101101
initStringInfoMy(&src);
102102
appendStringInfo(&src, SQL(
103-
WITH s AS (SELECT * FROM %1$s AS t WHERE "id" OPERATOR(pg_catalog.=) $1 FOR UPDATE OF t) INSERT INTO %1$s AS t ("parent", "plan", %2$s) SELECT "id", CASE
103+
WITH s AS (SELECT * FROM %1$s AS t WHERE "id" OPERATOR(pg_catalog.=) $1 FOR UPDATE OF t) INSERT INTO %1$s ("parent", "plan", %2$s) SELECT "id", CASE
104104
WHEN "drift" THEN %3$s OPERATOR(pg_catalog.+) "repeat" ELSE (WITH RECURSIVE r AS (SELECT "plan" AS p UNION SELECT p OPERATOR(pg_catalog.+) "repeat" FROM r WHERE p OPERATOR(pg_catalog.<=) %3$s) SELECT * FROM r ORDER BY 1 DESC LIMIT 1)
105-
END AS "plan", %2$s FROM s WHERE "repeat" OPERATOR(pg_catalog.>) '0 sec' LIMIT 1 RETURNING t.id
105+
END AS "plan", %2$s FROM s WHERE "repeat" OPERATOR(pg_catalog.>) '0 sec' LIMIT 1 RETURNING id
106106
), t->work->schema_table, columns, init_plan());
107107
pfree(columns);
108108
}

0 commit comments

Comments
 (0)