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.96) (envelope-from ) id 1vj6iK-006o49-0B for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jan 2026 02:15:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vj6iI-00Ffkx-13 for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jan 2026 02:15:54 +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.96) (envelope-from ) id 1vj6iH-00Ffkp-3B for pgsql-hackers@lists.postgresql.org; Fri, 23 Jan 2026 02:15:54 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vj6iF-000000002e2-2C2v for pgsql-hackers@lists.postgresql.org; Fri, 23 Jan 2026 02:15:53 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-42fbc544b09so1340495f8f.1 for ; Thu, 22 Jan 2026 18:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769134549; cv=none; d=google.com; s=arc-20240605; b=YP/sn7rXVb5NUWjoaKXCYOZ/znWOyWIubQzyguP3YwFxfqZ5NjP0NqhK729oQ7Mj8p acryVvA6rNTwpFwZtnpIo0PG9kpoSjAV0GfsYHSR4DnnBFDbNamG2ZA0/hUKqsUFklkW vOqZ+CQxFfgsIzZIh1W+8Ln9gCPv6tjfiraEcBOjBf5KIDNgBPotLsxB8YOxi53F9eaw /Q73B22kFNLPXx99JQaXnWR2V/EyWWQd5Tk9JLWbtnmetrupCyUB6vMLbyEwj7rASkJy ZPzJwEGfyQLicyzwObcRZn+lM7QmH5dAGSSTwTVmQeMOwKlpWvOqUHUhKxQCzvt0dTwI UXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=LMlFgXhMk9aXdzeemX1aR0lkwG4qtjxH7kWeQmNPmxU=; fh=l2Lr2a7WXbbULwCroNLz+iHiHzIIFHkX+2PkOCoWGgw=; b=NP+k0QNOZ11DTNMGeIV45fG9KMhXRCLB25ZhC9VgdTQw/amf3FG6VFFDSNj26LeDJe QBsUgo42DQaVh7lFqJpOhnZUduEsPQquUit9Afy/Pc1NSJjqpQ9xIXjlKw+0A+EWjOg6 aQ7tlrXM1k+36BQaqkt0cG+c90OovqMVeGcum1ah9fOqYaxC16fLEVAlCUgmfeLdWrmp 50T9sqpptrzAWX81pj5bfHB/WPs6MpBy4DlyhQ77YjpF5+Jtxpo9/qfyDpQCnGhvfUdh b6baXW8nQW25WEe8rMnJeULOqWwKLYPnJv/JAagLOLAomiStQ70jq+7EsR6sPgzAHK23 vg/w==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769134549; x=1769739349; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LMlFgXhMk9aXdzeemX1aR0lkwG4qtjxH7kWeQmNPmxU=; b=DBoZQDQzL/0ROARvMqtLpAZg+u5DFksPGEb5ExT9CdwP1Xe3970J3HwX+9txbs4aay Iz21grFyo6EYyB4HjGhr9NyKBERpn0ynMu6dh61z1t+ef1N6o9hJKyBcMO78yQFqS7FB 7E09pv8X+nQhly3RSrIDHxyBuEmumq6Fky5M7VfMk38I3rFtTy88AyGqXlZY/p7FpUS/ vX4ltsliNGMaQZBXzYuTWjwJHt2CnqoquFUkfdWrNHNdAvpX8BHCS2+BS9+T4DjfMCN9 ZeB2d2STrug9gQmxQkYG5Al90bSy5+8MqWHqLgsy0Clxsax8O+MZCCSy30v5/Oh6udRG ApYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769134549; x=1769739349; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LMlFgXhMk9aXdzeemX1aR0lkwG4qtjxH7kWeQmNPmxU=; b=i2oPsYL5c0z78GBFff4mFBKNsK/ohzVbHawhlJQvv/YFql3Md2fiVvQF4LYlm4EzFY XQRWSXSGsoOxGDvhGYx0IJ0AHVR87pX74L+VT8ooAC65Gl8BnAM/bf3YiryCCf4MNFWF vNv+XSGeLFu3pfvfZWrl6MtPVnFs4HxqxIzARELhfAHm3XBvGfboiiR7rw8mpQ9365ZG dp67fJlgLaD74Sv0N2C/11qqEiLjPA/c8iF0dUPW/TTfGGYRKp7EWpGhqB/4hrRQxjTQ g0npI4ZqYaXFQIhXtkCsswp3cWPnIfSzO89LoaH0z/bn5IlHqtSqRxNN7WRYohe3Nfdj fANw== X-Forwarded-Encrypted: i=1; AJvYcCVxkD3E4MMkEE97mUohqRB3/A6gt8Kz9xAEUskd3ruTPHyOkE2UNXHaQ6q9ONhWylZ5iE/9PpJeIf4fvgdc@lists.postgresql.org X-Gm-Message-State: AOJu0YwgAWsUEQaxQAvzj+XsOa+jT5VHHAHWbID9AmvuHY8i37Wlwk1s O4Td4eARNUo5GyWXjcnLoHMYGND8crIncUUBpftrfGkOcFNy84FTzy/d80GP+7TBcTHDw/lv7bN eIQn/ulcCHXbm7s+D9E8/0SFP5SPHRak= X-Gm-Gg: AZuq6aIGAcNYqR+1BVX1R29KJ0WwZKfCzhuIK6x9aRohagfCk/kLOdqU/Z1zx+NMd9e 7KDLoLS9/OO9MTo/LQAdv4LvydzIDFRpOyKU/o7PuAvTtf74LYuEmhehBzM8g9b8y5ZgDxGefcr wdwYIcb2OW3ODdrBcgzdDjQLWSN7F5M3rknbwdqGcTPz/ZHttCbR+g7pbdjPLYhHeQQe1FP6e4j nMv3Z5Ygd8d/wLus+iZrNOrXpxFv1RSkAAyuDdvbGZRljSGg6nNTebxs5DTpT0vR2fFEVkeE7HL Jh014NcQ8CPJg5WRx/rlEi8HOu3nJ69lUhTDrCp2fadNk2D3l+grTEBVvrvzGHB3/KfFUZac X-Received: by 2002:a05:6000:220d:b0:430:f494:6abb with SMTP id ffacd0b85a97d-435b15879ffmr2142729f8f.8.1769134549067; Thu, 22 Jan 2026 18:15:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Fri, 23 Jan 2026 15:15:37 +1300 X-Gm-Features: AZwV_Qhzs8Pg4ueSnchVLNMzEe2yByfAvvBwyqNgaH2WyIRn-41esqjwkun6xnQ Message-ID: Subject: Re: Patch: dumping tables data in multiple chunks in pg_dump To: Hannu Krosing Cc: Zsolt Parragi , Ashutosh Bapat , PostgreSQL Hackers , Nathan Bossart Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 23 Jan 2026 at 06:05, Hannu Krosing wrote: > > Fixing all the warnings I think overall this needs significantly more care and precision than what you've given it so far. For example, you have: + if(dopt->max_table_segment_pages != InvalidBlockNumber) + appendPQExpBufferStr(query, "pg_relation_size(c.oid)/current_setting('block_size')::int AS relpages, "); + else + appendPQExpBufferStr(query, "c.relpages, "); Note that pg_class.relpages is "int". Later the code in master does: tblinfo[i].relpages = atoi(PQgetvalue(res, i, i_relpages)); If you look in vacuum.c, you'll see "pgcform->relpages = (int32) num_pages;" that the value stored in relpages will be negative when the table is >= 16TB (assuming 8k pages). Your pg_relation_size expression is not going to produce an INT. It'll produce a BIGINT, per "select pg_typeof(pg_relation_size('pg_class') / current_setting('block_size')::int);". So the atoi() can receive a string of digits representing an integer larger than INT_MAX in this case. Looking at [1], I see: "7.22.1 Numeric conversion functions 1 The functions atof, atoi, atol, and atoll need not affect the value of the integer expression errno on an error. If the value of the result cannot be represented, *the behavior is undefined.*" And testing locally, I see that my Microsoft compiler will just return INT_MAX on overflow, whereas I see gcc does nothing to prevent overflows and just continues to multiply by 10 regardless of what overflows occur, which I think would just make the code work by accident. Aside from that, nothing in the documentation mentions that this is for "heap" tables only. That should be mentioned as it'll just result in people posting questions about why it's not working for some other table access method. There's also not much care for white space. You've introduced a bunch of whitespace changes unrelated to code changes you've made, plus there's not much regard for following project standard. For example, you commonly do "if(" and don't consistently follow the bracing rules, e.g: + for(chkptr = optarg; *chkptr != '\0'; chkptr++) + if(*chkptr == '-') Things like the following help convey the level of care that's gone into this: +/* + * option_parse_int + * + * Parse integer value for an option. If the parsing is successful, returns + * true and stores the result in *result if that's given; if parsing fails, + * returns false. + */ +bool +option_parse_uint32(const char *optarg, const char *optname, i.e zero effort gone in to modify the comments after pasting them from option_parse_int(). Another example: + pg_log_error("%s musst be in range %lu..%lu", Also, I have no comprehension of why you'd use uint64 for the valid range when the function is for processing uint32 types in: +bool +option_parse_uint32(const char *optarg, const char *optname, + uint64 min_range, uint64 max_range, + uint32 *result) In its current state, it's quite hard to take this patch seriously. Please spend longer self-reviewing it before posting. You could temporarily hard-code something for testing which makes at least 1 table appear to be larger than 16TB and ensure your code works. What you have is visually broken and depends on whatever the atoi implementation opts to do in the overflow case. These are all things diligent commiters will be testing and it's sad to see how little effort you're putting into this. How do you expect this community to scale with this quality level of patch submissions? You've been around long enough and should know and do better. Are you just expecting the committer to fix these things for you? That work does not get done via magic wand. Being on v10 already, I'd have expected the patch to be far beyond proof of concept grade. If you're withholding investing time on this until you see more community buy-in, then I'd suggest you write that and withhold further revisions until you're happy with the level of buy-in. I'm also still not liking your de-normalised TableInfo representation for "is_segment". IMO, InvalidBlockNumber should be used to represent open bounded ranges, and if there's no chunking, then startPage and endPage will both be InvalidBlockNumber. IMO, what you have now needlessly allows invalid states where is_segment == true and startPage, endPage are not set correctly. If you want to keep the code simple, hide the complexity in a macro or an inline function. There's just no performance reason to materialise the more complex condition into a dedicated boolean flag. If the quality level of this has not improved significantly by v11, count me out. David [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf