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 1udxJx-002sdM-8V for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 20:41:14 +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 1udxJw-002yJF-9O for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 20:41:12 +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 1udxJv-002yJ5-QI for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 20:41:12 +0000 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1udxJr-0006KK-13 for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 20:41:11 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7e32c9577ddso456736085a.0 for ; Mon, 21 Jul 2025 13:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1753130466; x=1753735266; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=7ECBqqYnf9oIy6u7yOSqUiTesEma/D/VYk3uf0j7Tjs=; b=UT+xAqYuiOmpvid6hlH99ezhrk6tlA+7B+FpsAxnjxjUiXfeL7WMZSI8YTyXEJRAck 4LpdRaxvB7/tMJ7Mc6W67gfyZeRglSAbtKu0/hya9BTwTbF3q0QgBSev0aaK3CI9nks4 IU0f9iWQ31VS+o871mL1b+pRF2BjPmnsqUhlJfVa82qfgYCGlq71EX8lYT+jQINO2Wy6 UxlMzBgjxpDTn1dNATh3n/XcRkwwrAHX4HVp0BRnivaBmKCrE4zFJVcAvNKxY6dxW6J+ Wgn0x13kSjMdIE6KEkUlxI02KWGY3jNrobuhX4SibDcYBm99MsSxR/myf2xCEKLWrAqT XUrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753130466; x=1753735266; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7ECBqqYnf9oIy6u7yOSqUiTesEma/D/VYk3uf0j7Tjs=; b=CwCJdV8kT4T83OpEHwDTgz846jSckKannAC7aTgib3znlUrWoDkzTQ2FrdJiVagYTC S0sdUQKyUk9QZIseG131+TCS/lEDNkFvsiH/JrKEotl4eZGS8aFq+d62nSN+0g8Zo+5S aDQhtM646xce5gmLRSOfneipijsf3yxvvuR/BMi8abzASFHaCeRCgOqquMSwPnVEOUeV prlYQQySuB9sUfD7ALE0yY6nX4/wyv94CTIgYsGPB0x/wsfWSOuCrngms0+yg+qEVWBR DWfYPbIRMS32PhBNTijbHvdXX2Wmo69/EdRNx0XrlUMd8CQWN1Tccc9tRnO5w4gjIl9D V9CQ== X-Forwarded-Encrypted: i=1; AJvYcCXT8yt+ZHzilIDcBXWixg/p0YIt8s+hpQKCDXhCP6TLFokzgDEH8qkt7gGucBsq4tHK/rrRqK4VSWfAbq6k@lists.postgresql.org X-Gm-Message-State: AOJu0YxRvw5WQbASALa+JbzOrV3Pwv0vsjGkSFOCsjsHBiqu4sP70EaS rCVS06QcZs3zkgg8O3x5P3AXXZeaQgmQk4F//6AsMmlvCSLtoM2VqH2LORc6vcJLAgY= X-Gm-Gg: ASbGncv6L/Kzy/mgbHrlYH1ZpMnXlzk9hHW24NPE77HGW2XDYhAlc9TdFedRsrhRe3z ZhevdHsMKeT94qDPwo5P69apqInizBW8D+0YfvC/2FkNCbYv2rICvsbXLmzvzXWAsm2snKnSHvx Rk8eE6s4jNJafRw/iL00yT/Y8cOA6z4xKpD4CsJ4ZFR19wn0wiA3KV9aZpymFuucfqmypwxKRYH 8DNYjUmtnWJ4/ininE1A0Vx6ynhka3bAJWkBGH37CG0UanVKcXhP7s5FanF6LZKWSYyudwrv4JA pf2KOH/+VpmnVR9g85t59Zv9I9TWUUOey5xwxZCV2fL7n8Qv+JOhC3UzrvBUUl8n1bTIhPK/LRu Rp8YHvFLADrKf0gblEWIqyHQMzFDWTg== X-Google-Smtp-Source: AGHT+IFtXZWebshMAywOdI0Q7UWY8XewknyA3WstBswK5a6NUVxMKW4mBHfDNuWFx5rQUpW3ShdZ9w== X-Received: by 2002:a05:620a:1792:b0:7e1:cb4a:6dbd with SMTP id af79cd13be357-7e3435eb95dmr3087571085a.32.1753130465653; Mon, 21 Jul 2025 13:41:05 -0700 (PDT) Received: from ?IPV6:2605:a601:a6b0:500::1cb? ([2605:a601:a6b0:500::1cb]) by smtp.googlemail.com with ESMTPSA id af79cd13be357-7e356c61497sm455411385a.80.2025.07.21.13.41.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Jul 2025 13:41:04 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------Ge2EVvHNrHZQJcCyHEwkA1rD" Message-ID: <3f22a8bb-29e8-40cc-97a1-309181da2c13@dunslane.net> Date: Mon, 21 Jul 2025 16:41:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor , Noah Misch Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , jian he , Srinath Reddy , pgsql-hackers@lists.postgresql.org References: <202503311812.vxg5b7rzfgf6@alvherre.pgsql> <616efe2c-3986-43cf-b88c-4435849acf9e@dunslane.net> <948154fe-0278-4f4c-8f5a-085e12f03163@dunslane.net> <20250708212819.09.nmisch@google.com> <20250716001957.c6.nmisch@google.com> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNJEFuZHJldyBEdW5zdGFuIDxhbmRyZXdAZHVuc2xhbmUubmV0PsLAlwQTAQgAQQIbAwIX gAIZAQULCQgHAwUVCgkICwUWAgMBAAIeBRYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNGd BQkdEO8nAAoJEJn6f8tZ/DuBq74H/jkTR4Zi3stbw+xC7v2u3QozssK7MYPL2AsVfh7OealS h182fiWXpfvmmAB7WUHbhk9GC2RAOnHI/2d2jgKaMLAHsGYOT0YopTVIwRY43fCw/mK67yxc wmDcX+zyKfLaivNbf5A7QPLNwda98bEAMSJ8Sn652Uc6cA8t3uKGsVzbRBQOoYzjgvBCfSrE 9ql3PDNg0l4BfAqabd2f70ZUm9VAMEPrgv/v2xI7M2XiL4g5BVmqLCOwxLM8RMCotCuoweUr VO43DeBCIDwLxotMJKvGWDjBzQYlU1NPUAtNcz/gN9ITUe1VUGjyvGj4u1lxBOcQQUw7l1+T 5moZ4iZxXzvOwE0ETspYWQEIANGc4zQULOxhbqO2dyD51YhqCNRmm9oKWaqf+wmW4tpDe/VV cxAnNizd4LWCHfzpb5cHAtGkOPePMfzWVf6nvdF7d3eglbtf59+zG7O7llV0xSSoFiieQBsr GvqDInXYX/4mRRXMtyhM353/tixC9RWLs1oofyYmCPPXXY7h9R7en3B8BoVrRFcdzlIY/NFN hFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C4R+M6w7o2PLGOjdZ +kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaYL++LAEOqrlvm2Tvq QqZRtnEAEQEAAcLAfAQYAQgAJgIbDBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNI2BQkd EODdAAoJEJn6f8tZ/DuBfw0IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: 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. --------------Ge2EVvHNrHZQJcCyHEwkA1rD Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025-07-17 Th 6:18 AM, Mahendra Singh Thalor wrote >>>>>> --- a/src/bin/pg_dump/pg_restore.c >>>>>> +++ b/src/bin/pg_dump/pg_restore.c >>>>>> +/* >>>>>> + * read_one_statement >>>>>> + * >>>>>> + * This will start reading from passed file pointer using fgetc and read till >>>>>> + * semicolon(sql statement terminator for global.dat file) >>>>>> + * >>>>>> + * EOF is returned if end-of-file input is seen; time to shut down. >>>>> What makes it okay to use this particular subset of SQL lexing? >>>> To support complex syntax, we used this code from another file. >>> I'm hearing that you copied this code from somewhere. Running >>> "git grep 'time to shut down'" suggests you copied it from >>> InteractiveBackend(). Is that right? I do see other similarities between >>> read_one_statement() and InteractiveBackend(). >>> >>> Copying InteractiveBackend() provides negligible assurance that this is the >>> right subset of SQL lexing. Only single-user mode uses InteractiveBackend(). >>> Single-user mode survives mostly as a last resort for recovering from having >>> reached xidStopLimit, is rarely used, and only superusers write queries to it. >> Yes, we copied this from InteractiveBackend to read statements from >> global.dat file. Maybe we should ensure that identifiers with CR or LF are turned into Unicode quoted identifiers, so each SQL statement would always only occupy one line. Or just reject role and tablespace names with CR or LF altogether, just as we do for database names. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------Ge2EVvHNrHZQJcCyHEwkA1rD Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2025-07-17 Th 6:18 AM, Mahendra Singh Thalor wrote
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c

              
+/*
+ * read_one_statement
+ *
+ * This will start reading from passed file pointer using fgetc and read till
+ * semicolon(sql statement terminator for global.dat file)
+ *
+ * EOF is returned if end-of-file input is seen; time to shut down.
What makes it okay to use this particular subset of SQL lexing?
To support complex syntax, we used this code from another file.
I'm hearing that you copied this code from somewhere.  Running
"git grep 'time to shut down'" suggests you copied it from
InteractiveBackend().  Is that right?  I do see other similarities between
read_one_statement() and InteractiveBackend().

Copying InteractiveBackend() provides negligible assurance that this is the
right subset of SQL lexing.  Only single-user mode uses InteractiveBackend().
Single-user mode survives mostly as a last resort for recovering from having
reached xidStopLimit, is rarely used, and only superusers write queries to it.
Yes, we copied this from InteractiveBackend to read statements from
global.dat file.



Maybe we should ensure that identifiers with CR or LF are turned into Unicode quoted identifiers, so each SQL statement would always only occupy one line. Or just reject role and tablespace names with CR or LF altogether, just as we do for database names.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------Ge2EVvHNrHZQJcCyHEwkA1rD--