Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBvwu-00CzAk-QU for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2023 11:56:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rBvwt-0005Fj-4F for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2023 11:56:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBvws-0005Eh-Qh for pgsql-hackers@lists.postgresql.org; Sat, 09 Dec 2023 11:56:46 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rBvwl-00AzVc-Or for pgsql-hackers@postgresql.org; Sat, 09 Dec 2023 11:56:46 +0000 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-35d57ab6f5bso72985ab.0 for ; Sat, 09 Dec 2023 03:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702122998; x=1702727798; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=R2oapC79EvSyR1nWXJ2zB5A/4KZQttZIRISR7ny9lAw=; b=VK6YMdYhZqHXueoDCYJ89NwV/EVyIwhldqx1hkDtL7UdLgQizeLLl4z4EzvUbGbcIT p3ecPv2vNSiw3yYEtmmfkh0CWJxbZraXqiCLaFVduSkvdXY+zfpwEcFItwDpZtm3SgYp 3xhQAQgbivyV83g4QG9k91Sdms8yELkvyKqZBCL+WP6CwfMyHFfZ8n3hdCOxPRwlmMm4 sW69UqOpgLfrH0m06kRhI9WDM+B9Y2uORuSiz8cLgLpSxEueUj/AzszExTinzHaYsf/F hcXUTF4H7OUrolznmrjuMm4N1B+5c+R1Ily86uxPvwfDYWJQeL/mbA8dvlAXlb5AGPtS 6Gjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702122998; x=1702727798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R2oapC79EvSyR1nWXJ2zB5A/4KZQttZIRISR7ny9lAw=; b=kZTR7VW6oVjXTNZyAKamZdtE/tEd4bS0PXn/3SXZaj5uw1Nm5cai7vRA6Yh2sbGVYk tIEiNZ0lUSCTn9OQaffL/149lZ0oUU5OduZOF4fpq8eT3OBs1ncvbH35dK0U0+xyaOJ4 5jMWriZLU79xB/q6CrlcxCacUzPWhi0k44Q4eyRQFSx3qWbBhLW79Q/htGtzMrQ4Ks2U yDGc/iOTTR84jXf3QCcSsymt6QnMkDboygDlH8gw2S+zGBZYMezWQBhb6GJJxV89eH4D nh2LsYo9iB2OUWojaPLnXstmxF/l4GbhnaDjE7TGXncEYri1H4zRunW01ZihZQ0k3muH Hu2A== X-Gm-Message-State: AOJu0YySMAVoBOJUSyu0e82BhLHFC8SjMWHAUdiVtkCmNTEStMVoWrh5 jyCNQO4weW5swQXYoIPobXbJwoNXa7V61iWrnIkHPA== X-Google-Smtp-Source: AGHT+IFkLrhLSIUBlB479OpX+xjvba1m0iDIUDZh6rK8ZG1aJvCPoDSBTpl5nXmWWMVU0RLfjaTficN+BwQPggJLelA= X-Received: by 2002:a05:6e02:1e0b:b0:35d:58e0:c496 with SMTP id g11-20020a056e021e0b00b0035d58e0c496mr477905ila.15.1702122997533; Sat, 09 Dec 2023 03:56:37 -0800 (PST) MIME-Version: 1.0 References: <3853387.1701096982@sss.pgh.pa.us> <3a98decf-3fe3-4b49-9b68-fda01338872c@sedlakovi.org> <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> <20231201230958.GA1786735@nathanxps13> <411395e0-697e-44ab-be98-dd2047f9a10e@joeconway.com> <398150.1701529880@sss.pgh.pa.us> In-Reply-To: <398150.1701529880@sss.pgh.pa.us> From: Hannu Krosing Date: Sat, 9 Dec 2023 12:56:23 +0100 Message-ID: Subject: Re: Emitting JSON to file using COPY TO To: Tom Lane Cc: Joe Conway , Nathan Bossart , Davin Shearer , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sat, Dec 2, 2023 at 4:11=E2=80=AFPM Tom Lane wrote: > > Joe Conway writes: > >> I noticed that, with the PoC patch, "json" is the only format that mus= t be > >> quoted. Without quotes, I see a syntax error. In longer term we should move any specific COPY flag names and values out of grammar and their checking into the parts that actually implement whatever the flag is influencing Similar to what we do with OPTIONS in all levels of FDW definitions (WRAPPER itself, SERVER, USER MAPPING, FOREIGN TABLE) [*] https://www.postgresql.org/docs/current/sql-createforeigndatawrapper.ht= ml > >> I'm assuming there's a > >> conflict with another json-related rule somewhere in gram.y, but I hav= en't > >> tracked down exactly which one is causing it. > > While I've not looked too closely, I suspect this might be due to the > FORMAT_LA hack in base_yylex: > > /* Replace FORMAT by FORMAT_LA if it's followed by JSON */ > switch (next_token) > { > case JSON: > cur_token =3D FORMAT_LA; > break; > } My hope is that turning the WITH into a fully independent part with no grammar-defined keys or values would also solve the issue of quoting "json". For backwards compatibility we may even go the route of keeping the WITH as is but add the OPTIONS which can take any values at grammar level. I shared my "Pluggable Copy " talk slides from Berlin '22 in another thread -- Hannu