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 1uFd4a-006mmg-Q2 for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 18:12:49 +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 1uFd4Z-00G1Zm-Gm for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 18:12:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uFd4Z-00G1ZR-8N for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 18:12:47 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uFd4W-001xW7-1V for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 18:12:46 +0000 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-4774ce422easo13024441cf.1 for ; Thu, 15 May 2025 11:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747332764; x=1747937564; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=jCoogi6zCe3mgRdcjRV8ET7ibK331XY9ojdqq/uZFQA=; b=Re31kSWokjgM6M61+N03Y3iQdKfiN6yEtrd/olnE06hAyOWjWGsljotBV+/Erldb05 M5lLVwSoeG2XubvM3nip0Gt7Tl0tWseNi51jE9eONc4ccevmJx1ZLFR886jkKUgR9Nbr NGYvoO2WXRPQt18q9nKY+QYbPOUBPPdbQA1QIRZLK03Vr1WAV7JV21P6Qmuk4EEidMI5 ox/b+tQpzxtSKt0FGVvXw0XzCN0Qzr8NjiZsm1dDt0sr9/dCxY0Ec7puYhbA/bBFNRQ1 hD6PQmDO8YoDsIrjKgSs7NI6bLC15GoWWaX3GS9/LC/FTQchpAMWYQyWI2tyu+XUilz+ Qw/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747332764; x=1747937564; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jCoogi6zCe3mgRdcjRV8ET7ibK331XY9ojdqq/uZFQA=; b=FSZbGU3Zynue+Lm11DgP71fQPkmxUkN6WwIsHsiYznI3p8fzAG1PA7twDeNAeh3Kan +ifJL9N9LmzmlNQh4rNk8Nqqgb9LkPRe72J2eZ3Lci4g6c0JdqD5xjIpPmtwBR2/ZA05 Ui99ewsjWh3+11BmzBCvBI5CLY8ph1ChoDEignWsjFMjQwSD0kNsRhMYoYqrQZGXVTsX 1UZ+6Bx2BgyYQUORXo3ltPUTRPRahSG7HVCC08dL1xPoxkQPUzYX3ACXNT38nskw1nUg 2DvJdwbgfbcXIMwIa3O7693OA/rK853gaE6MCD4ZPGSkLkSBi2tSMOg+qiOLj4bXxn8f nQpQ== X-Forwarded-Encrypted: i=1; AJvYcCUcacHctv57kCf0CMQdNMKGhEH1lGwc1dft17nO9I6Fh1GV+rpq/ejtloYjmF5YF03fnYdx81D16d1C@lists.postgresql.org X-Gm-Message-State: AOJu0Yz3yWW22UtJ+ZxOlmOzTB5gxK6s3AFFfPnyamcy9Dq67gI+4yMq ipeQ4Bw77DFVzocK5NEeJohqCTDDzhcwd31NxggfO87TBLa+AyHwZrdD X-Gm-Gg: ASbGncunjkwFCyEvpjuEWwRjCmqjK2Ouh7pxXUnt8kWFYRhYsg02zL3hZIlJzjDETeD OH5trdceuZ2rI7BabRyFeT/dnSwsnM0saeAiXEC+FkdL7PKWX4xc43OV8AtcCic39I9A5aQZXTa SyhZgiG2ZRlhu9N4DBa6Qh+e/UQ/8Q54rCcJVy53NMo1CfU5wIBlMnxwwKn0L5SbH3mgN+IHGzx 6y0VGtjco6sY3ZgjxZwxcjsSvrLbtGqsEe03ExlPigBNxHUI7AhrWgjWj7Cs7WQrowdq5w684dS WqUN0E5QhVCsdzhuCVg+RhAvKGWzyGT465e7O4sOB/ACQfZyQJjy316t5oHMkF2Po1Od6cF9Xml df7sQOcI+yLBytbbyiaWa5rHqp7hffuazGw== X-Google-Smtp-Source: AGHT+IGgIpCib+/91HGODB1vLwdMclAq5S9V3u6vJjLnJclU3JA3G8YI6iHYIwPIbbFyKDecFdKuAQ== X-Received: by 2002:a05:622a:424a:b0:476:923a:ca79 with SMTP id d75a77b69052e-494ae365729mr5952761cf.7.1747332763978; Thu, 15 May 2025 11:12:43 -0700 (PDT) Received: from nathan (modemcable171.6-163-184.mc.videotron.ca. [184.163.6.171]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-494ae4fd741sm929361cf.54.2025.05.15.11.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 May 2025 11:12:43 -0700 (PDT) Date: Thu, 15 May 2025 14:12:41 -0400 From: Nathan Bossart To: jian he Cc: Tom Lane , phb.emaj@free.fr, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18923: pg_dump 18beta1 fails to process complex table names Message-ID: References: <18923-e79273f87c6bed69@postgresql.org> <37115.1747057899@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xHlpTG+cgUMwKgcC" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xHlpTG+cgUMwKgcC Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, May 13, 2025 at 07:34:51PM +0800, jian he wrote: > On Mon, May 12, 2025 at 9:51 PM Tom Lane wrote: >> PG Bug reporting form writes: >> > I have just run the E-Maj project regression test suite with PG18 beta1 and >> > found a pg_dump abort when trying to dump a schema prefixed table having a >> > complex name including single quote, double quote and space. >> >> Thanks for the report! Looks like fetchAttributeStats() is completely >> misguided about the appropriate quoting rules for array elements. D'oh, my bad. > re-read ReadArrayToken. > In this context, we need to care about single-quote, double-quotes. > for backslash, we skip it. > > appendPGArray can help us handle double quotes, > now we just need to make it also handle single quotes. I don't think we want to teach appendPGArray() to handle single quotes. That's meant for building a text representation of a 1-dimensional Postgres array, which IIUC doesn't need to escape single quotes. Take the following example: postgres=# select array['nathan''s element']; array ---------------------- {"nathan's element"} (1 row) My first instinct is that we need to build the array with appendPGArray() and then append it to the query using appendStringLiteralAH(), as done in the attached patch. -- nathan --xHlpTG+cgUMwKgcC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0001-pg_dump-fix-quoting-in-fetchAttributeStats.patch