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 1scYfM-008RH8-Kt for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2024 23:05:00 +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 1scYfK-006YkB-DM for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2024 23:04:58 +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 1scYfJ-006Yk3-Uw for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2024 23:04:58 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1scYfD-0042k5-28 for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2024 23:04:57 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3db50abf929so1858485b6e.2 for ; Fri, 09 Aug 2024 16:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20230601.gappssmtp.com; s=20230601; t=1723244688; x=1723849488; darn=lists.postgresql.org; h=content-transfer-encoding:subject:to:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=BhXflroKHcx/Cyr+URXvmQVjw4Jf5haOzzB1BZnDsxU=; b=fMlUSEotiJgp+MWxoxNJnb+lIVHwolWHlLpCmO4PlBUZbSsYkdicId3BDulRIt5mhy U6Mp75JRX23vTEk6hs7p0SccLKyNYPB1t+d7n5f8gbYgbfFSHbICata5EKeUlhVSFeo0 +G3vKKyf0VYqY8KmZu4srZRDhqOMn5wB+VoHIWaUnvfQcpP86hewjxV5WoJaClC3B5G2 ixjEsVhhF5ubqn1QuDlZ/HkOsJQQIizqgG6JYiTYbEx4koQNKzOFpsOxOTi65xRf4ZLY o6Gr/qg3WrG9lXZXrXBxDNK8qikDI4978dcXUQnpt7x9hQa56HYilXP2NZ/9h2zNIQxY 8vRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723244688; x=1723849488; h=content-transfer-encoding:subject:to:from:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=BhXflroKHcx/Cyr+URXvmQVjw4Jf5haOzzB1BZnDsxU=; b=iNwiKZXlP2ruQf+ues0MeIyVHt8H7tvEh1BGQSrAkKQ3KzkxNsgyGLkWmRiV3KQ+Cw hYmlrpo7ZvJ0tRP0AFv89UZaCBziaxBUFDFQ8OIJfKskoKaVFGcmX3QRztvzeSlM0Lp5 QoibyY2F5pzKh+8YOognqNUTLG2smEfOSX9n3y1BZoTBA0JzeaeNOEwdix+p1av9HhPp 76yQUyUWtsuNNGPFW416w8GiQ1tOI9ghYAZXbAv6XlHZnkVZHO1Ne1zvHEIwlE8YOUHK vwiHy5X6rRnAkD7k7tB5UFggA/UzWLxpvlrUN2evUY+pXfrcBtJfbjGp21tfyBqC2DIa VPNw== X-Gm-Message-State: AOJu0Yx7EpchvUH1XCdZeSMfRv7QZ014wHfn0iUXpIs4ic1oNLd1nbR0 9XXkeNuyk8w1zWAoF1Xyf5CTAPd9tY2nXodApEvdXv8UC7v+tCXDAnz42odl2//oYJ6iER0+XFY X X-Google-Smtp-Source: AGHT+IG1VT107xoAybUBVx6oJ6YXlr+Vnk+78N9On9UBMzxIC81dnEJmLBdvSyhUuy0B0JjYQCe02Q== X-Received: by 2002:a05:6870:e393:b0:261:19a6:41ae with SMTP id 586e51a60fabf-26c62d20632mr3785829fac.30.1723244687996; Fri, 09 Aug 2024 16:04:47 -0700 (PDT) Received: from [192.168.2.139] ([50.39.255.79]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-7c3dbea381dsm196552a12.81.2024.08.09.16.04.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Aug 2024 16:04:47 -0700 (PDT) Message-ID: <286814e4-46d4-44d6-be45-c2ee979021e1@illuminatedcomputing.com> Date: Fri, 9 Aug 2024 16:04:45 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Paul Jungwirth To: PostgreSQL Hackers Subject: format_datum debugging function Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Hackers, Often in a debugger I've wanted to way to print Datums, in particular non-trivial ones like range types. This came up a lot when I was working on multiranges, and I've wished for it lately while working on UPDATE/DELETE FOR PORTION OF. But all the obvious approaches are inlined functions or preprocessor macros, so they aren't available. Usually I wind up giving up on gdb and adding elog statements. Once or twice I've copy/pasted from the three or four levels of nested macros to make gdb do what I wanted, but it's a pain. I assumed printing a Datum was easy, and I was the only one who didn't know how to do it. But perhaps not. The conversation about print.c [1] made me think I should propose a way to make it easier. This function takes a Datum and the appropriate out function, and returns a char *. So you can do this: (gdb) call format_datum(range_out, $1) $2 = 0x59162692d938 "[1,4)" I assume a patch like this doesn't need documentation. Does it need a test? Anything else? [1] https://www.postgresql.org/message-id/flat/7d023c20-6679-44bd-b5f7-44106659bd5a%40eisentraut.org Yours, -- Paul ~{:-) pj@illuminatedcomputing.com