Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFk4k-0005CG-VB for pgsql-general@arkaria.postgresql.org; Thu, 03 Feb 2022 21:55:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nFk4j-0006nQ-Lv for pgsql-general@arkaria.postgresql.org; Thu, 03 Feb 2022 21:55:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFk4j-0006nF-Cb for pgsql-general@lists.postgresql.org; Thu, 03 Feb 2022 21:55:33 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nFk4h-0001DQ-9y for pgsql-general@lists.postgresql.org; Thu, 03 Feb 2022 21:55:32 +0000 Received: by mail-oi1-x229.google.com with SMTP id x193so6373515oix.0 for ; Thu, 03 Feb 2022 13:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=HOGRmDasXVAIBGArJlXsrvTRXUTYw+9TNb/0cLyL1X8=; b=PsgVRUOXquF0bf/WgNIhGlgq19rIyFzviIG7o6jCm1EiG6hoy1EO/nZwYZqwzbRdy+ Ugz1lmYwiUMPgCVHjtSsdMX33SnezkfZXzQvHQOMEk3XnoCcfqdGLfcOWqNaBkZtK8BX EBN28guM4Slgd1B1Ze/p43UPdfIppKrOGVyainpwQvBbABPVEB+oycxp53YIw4WOMFYf +mnc9qO2yOPefddBkB5rM0iKMW3hMJ4wpoxAR+N4xEa0PBtWrLN9KECY61FeIZ/0UBKa 20/mWo+sNnaUJGLEb76wZ+80Nm+hBeHSu0Z9QthSNE0cLB+d6t9Abd08FJY29sou6Exi cqCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=HOGRmDasXVAIBGArJlXsrvTRXUTYw+9TNb/0cLyL1X8=; b=o0mNqz4d/Nm6wJQUmSGzJ0EatNhWjPOciG7nk6gOIeaoQO3+ofinlLOY05Uw4odCo3 Vq101BOO4tYrYRUu3k0orFZ23zHwF5E+aZe7uwvTLwgquFD4iowDGiA7gmKza5D5VYtH c5kUdNsI/3zQtOnvUhw6NzvHejRctEdeL81DnnjxNztwPF8YRwSPTLmLgHWGFfzcBn5n 6zEQnsmEeLyJVW5Gur4BEBX0ai1Prc9JRmnaHCMxXHcITDCgzHh1qHfraHBstc54NzAI oZZ2IO82tC0WI9qfWrig3vYvQvVCLX4IrKarxZjx+V/tpd4cTd2FWEPU9A707fJ8w98o iw2w== X-Gm-Message-State: AOAM532pItg20xS6oPEQmauHUA/ESBOuKukHKAow7JrmQaCBqIVwIfpS +JKuSmRBPnFoP4dRxPzVyRNGtsfnxD4= X-Google-Smtp-Source: ABdhPJyQpuAL+bsM1X2A5bQoMBFK9MZztj2J0ZS+bleFxdJhhR5+hFmaXWa+fHSpiKlXfMQe+9BsZw== X-Received: by 2002:aca:5e55:: with SMTP id s82mr8498965oib.109.1643925330245; Thu, 03 Feb 2022 13:55:30 -0800 (PST) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id y19sm51413oti.49.2022.02.03.13.55.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 13:55:29 -0800 (PST) Subject: Re: pg_cron for vacuum - dynamic table set To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: Date: Thu, 3 Feb 2022 15:55:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------95ADA74481B6D7AB9D81EDAB" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------95ADA74481B6D7AB9D81EDAB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/3/22 3:29 PM, saket bansal wrote: > Hi, I am trying to schedule pg_cron to generate a set of commands and then > run them. E.g |select 'vacuum freeze '||table_name from > inventory_for_vacuum \gexec| . This works well at command line, but when > scheduled in pg_cron, it fails with syntax error |ERROR: syntax error at > or near "\"| . > Since vacuum doesn't work inside a transaction block |ERROR: VACUUM cannot > run inside a transaction block|, I cannot use a function directly to run > over a loop. > Any guidance to make it work or an alternative? What about running the command from regular cron? -- Angular momentum makes the world go 'round. --------------95ADA74481B6D7AB9D81EDAB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 2/3/22 3:29 PM, saket bansal wrote:
Hi, I am trying to schedule pg_cron to generate a set of commands and then run them. E.g select 'vacuum freeze '||table_name from inventory_for_vacuum \gexec . This works well at command line, but when scheduled in pg_cron, it fails with syntax error ERROR: syntax error at or near "\" .
Since vacuum doesn't work inside a transaction block ERROR: VACUUM cannot run inside a transaction block, I cannot use a function directly to run over a loop.
Any guidance to make it work or an alternative?

What about running the command from regular cron?

--
Angular momentum makes the world go 'round.
--------------95ADA74481B6D7AB9D81EDAB--