Re: Extending outfuncs support to utility statements
Alexander Law <exclusion@gmail.com>
From: Alexander Lakhin <exclusion@gmail.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org
Date: 2023-03-19T12:00:01Z
Lists: pgsql-hackers
Hello, 26.09.2022 17:46, Peter Eisentraut wrote: > On 22.09.22 23:21, Tom Lane wrote: >> Anyway, this is a bit far afield from the stated topic of this >> thread. I think we should commit something approximately like >> what I posted and then start a new thread specifically about >> what we'd like to do about utility commands in new-style SQL >> functions. > > Right, I have committed everything and will close the CF entry. I don't have a specific idea about how to move > forward right now. Please look at the function _readA_Const() (introduced in a6bc33019), which fails on current master under valgrind: CPPFLAGS="-DUSE_VALGRIND -DWRITE_READ_PARSE_PLAN_TREES -Og " ./configure -q --enable-debug && make -s -j8 && make check ============== creating temporary instance ============== ============== initializing database system ============== pg_regress: initdb failed Examine .../src/test/regress/log/initdb.log for the reason. initdb.log contains: performing post-bootstrap initialization ... ==00:00:00:02.155 3419654== Invalid read of size 16 ==00:00:00:02.155 3419654== at 0x448691: memcpy (string_fortified.h:29) ==00:00:00:02.155 3419654== by 0x448691: _readA_Const (readfuncs.c:315) ==00:00:00:02.155 3419654== by 0x44CCD2: parseNodeString (readfuncs.switch.c:129) ==00:00:00:02.155 3419654== by 0x4348D6: nodeRead (read.c:338) ==00:00:00:02.155 3419654== by 0x434879: nodeRead (read.c:452) ==00:00:00:02.155 3419654== by 0x440E6C: _readTypeName (readfuncs.funcs.c:830) ==00:00:00:02.155 3419654== by 0x44CC3A: parseNodeString (readfuncs.switch.c:121) ==00:00:00:02.155 3419654== by 0x4348D6: nodeRead (read.c:338) ==00:00:00:02.155 3419654== by 0x43D51D: _readFunctionParameter (readfuncs.funcs.c:2513) ==00:00:00:02.155 3419654== by 0x44DE0C: parseNodeString (readfuncs.switch.c:367) ==00:00:00:02.155 3419654== by 0x4348D6: nodeRead (read.c:338) ==00:00:00:02.155 3419654== by 0x434879: nodeRead (read.c:452) ==00:00:00:02.155 3419654== by 0x438A9C: _readCreateFunctionStmt (readfuncs.funcs.c:2499) ==00:00:00:02.155 3419654== Address 0xf12f718 is 0 bytes inside a block of size 8 client-defined ==00:00:00:02.155 3419654== at 0x6A70C3: MemoryContextAllocZeroAligned (mcxt.c:1109) ==00:00:00:02.155 3419654== by 0x450C31: makeInteger (value.c:25) ==00:00:00:02.155 3419654== by 0x434D59: nodeRead (read.c:482) ==00:00:00:02.155 3419654== by 0x448690: _readA_Const (readfuncs.c:313) ==00:00:00:02.155 3419654== by 0x44CCD2: parseNodeString (readfuncs.switch.c:129) ==00:00:00:02.155 3419654== by 0x4348D6: nodeRead (read.c:338) ==00:00:00:02.155 3419654== by 0x434879: nodeRead (read.c:452) ==00:00:00:02.155 3419654== by 0x440E6C: _readTypeName (readfuncs.funcs.c:830) ==00:00:00:02.155 3419654== by 0x44CC3A: parseNodeString (readfuncs.switch.c:121) ==00:00:00:02.155 3419654== by 0x4348D6: nodeRead (read.c:338) ==00:00:00:02.155 3419654== by 0x43D51D: _readFunctionParameter (readfuncs.funcs.c:2513) ==00:00:00:02.155 3419654== by 0x44DE0C: parseNodeString (readfuncs.switch.c:367) ==00:00:00:02.155 3419654== Here _readA_Const() performs: union ValUnion *tmp = nodeRead(NULL, 0); memcpy(&local_node->val, tmp, sizeof(*tmp)); where sizeof(union ValUnion) = 16, but nodeRead()->makeInteger() produced Integer (sizeof(Integer) = 8). Best regards, Alexander
Commits
-
Avoid copying undefined data in _readA_Const().
- e060cd59fabd 16.0 landed
-
Enable WRITE_READ_PARSE_PLAN_TREES of rewritten utility statements
- 787102b56373 16.0 landed
-
Implement WRITE_READ_PARSE_PLAN_TREES for raw parse trees
- 40ad8f9deed2 16.0 landed
-
Don't lose precision for float fields of Nodes.
- acd624644bc4 16.0 landed
-
Fix write/read of empty string fields in Nodes.
- 8999f5ed3cd7 16.0 landed
-
Add read support for some missing raw parse nodes
- a6bc3301925e 16.0 landed
-
Fix reading of BitString nodes
- 2cb1a5a8d4ae 16.0 landed
-
Fix reading of most-negative integer value nodes
- 43f4b349152d 16.0 landed