From: | gmail Vladimir Koković <vladimir(dot)kokovic(at)gmail(dot)com> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #15653: pg_detoast_datum_packed problem |
Date: | 2019-03-09 09:03:38 |
Message-ID: | 5236e747-2107-35f8-6741-99298f0bd6a4@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi Andrew.
I changed VARSIZE to VARSIZE_ANY_EXHDR and VARDATA in VARDATA_ANY as you
said, but there is still a problem I can not understand ! 124 Datum
pg_bvarchar(PG_FUNCTION_ARGS) { 125 VarChar *arg =
PG_GETARG_VARCHAR_PP(0); 0x7f5b4adb1380 <pg_bvarchar>: push r13 -
0x7f5b4adb1382 <pg_bvarchar+2>: push r12 - 0x7f5b4adb1384
<pg_bvarchar+4>: push rbp - 0x7f5b4adb1385 <pg_bvarchar+5>: push rbx -
0x7f5b4adb1386 <pg_bvarchar+6>: sub rsp,0x8 - 0x7f5b4adb138a
<pg_bvarchar+10>: mov rdi,QWORD PTR [rdi+0x20] - 0x7f5b4adb138e
<pg_bvarchar+14>: call 0x7f5b4adb1030 <pg_detoast_datum_packed(at)plt> -
0x7f5b4adb1393 <pg_bvarchar+19>: mov rbx,rax 126 unsigned len; 127 bytea
*res; 128 129 len = VARSIZE_ANY_EXHDR(arg) - VARHDRSZ; - 0x7f5b4adb1396
<pg_bvarchar+22>: movzx eax,BYTE PTR [rax] - 0x7f5b4adb1399
<pg_bvarchar+25>: cmp al,0x1 - 0x7f5b4adb139b <pg_bvarchar+27>: je
0x7f5b4adb1408 <pg_bvarchar+136> - 0x7f5b4adb139d <pg_bvarchar+29>: test
al,0x1 - 0x7f5b4adb139f <pg_bvarchar+31>: jne 0x7f5b4adb13f0
<pg_bvarchar+112> - 0x7f5b4adb13a1 <pg_bvarchar+33>: mov eax,DWORD PTR
[rbx] - 0x7f5b4adb13a3 <pg_bvarchar+35>: shr eax,0x2 - 0x7f5b4adb13a6
<pg_bvarchar+38>: lea edi,[rax-0x4] - 0x7f5b4adb13a9 <pg_bvarchar+41>:
lea r13d,[rax-0x8] - 0x7f5b4adb13ad <pg_bvarchar+45>: mov r12,rdi -
0x7f5b4adb13b0 <pg_bvarchar+48>: shl r12d,0x2 130 res = (text *)
palloc(len + VARHDRSZ); - 0x7f5b4adb13b4 <pg_bvarchar+52>: call
0x7f5b4adb1050 <palloc(at)plt> - 0x7f5b4adb13b9 <pg_bvarchar+57>: lea
rsi,[rbx+0x4] - 0x7f5b4adb13bd <pg_bvarchar+61>: mov rdx,r13 -
0x7f5b4adb13c0 <pg_bvarchar+64>: mov rbp,rax 131 SET_VARSIZE(res, len +
VARHDRSZ); - 0x7f5b4adb13c3 <pg_bvarchar+67>: mov DWORD PTR [rax],r12d
132 memcpy(VARDATA(res), VARDATA_ANY(arg), len); - 0x7f5b4adb13c6
<pg_bvarchar+70>: lea rax,[rbx+0x1] - 0x7f5b4adb13ca <pg_bvarchar+74>:
test BYTE PTR [rbx],0x1 - 0x7f5b4adb13cd <pg_bvarchar+77>: cmovne
rsi,rax - 0x7f5b4adb13d1 <pg_bvarchar+81>: lea rdi,[rbp+0x4] -
0x7f5b4adb13d5 <pg_bvarchar+85>: call 0x7f5b4adb1040 <memcpy(at)plt>
Program terminated with signal SIGSEGV, Segmentation fault. 133
PG_RETURN_BYTEA_P(res); - 0x7f5b4adb13da <pg_bvarchar+90>: add rsp,0x8 -
0x7f5b4adb13de <pg_bvarchar+94>: mov rax,rbp - 0x7f5b4adb13e1
<pg_bvarchar+97>: pop rbx - 0x7f5b4adb13e2 <pg_bvarchar+98>: pop rbp -
0x7f5b4adb13e3 <pg_bvarchar+99>: pop r12 - 0x7f5b4adb13e5
<pg_bvarchar+101>: pop r13 - 0x7f5b4adb13e7 <pg_bvarchar+103>: ret -
0x7f5b4adb13e8 <pg_bvarchar+104>: nop DWORD PTR [rax+rax*1+0x0] -
0x7f5b4adb13f0 <pg_bvarchar+112>: shr al,1 - 0x7f5b4adb13f2
<pg_bvarchar+114>: movzx eax,al - 0x7f5b4adb13f5 <pg_bvarchar+117>: lea
edi,[rax-0x1] - 0x7f5b4adb13f8 <pg_bvarchar+120>: lea r13d,[rax-0x5] -
0x7f5b4adb13fc <pg_bvarchar+124>: mov r12,rdi - 0x7f5b4adb13ff
<pg_bvarchar+127>: shl r12d,0x2 - 0x7f5b4adb1403 <pg_bvarchar+131>: jmp
0x7f5b4adb13b4 <pg_bvarchar+52> - 0x7f5b4adb1405 <pg_bvarchar+133>: nop
DWORD PTR [rax] - 0x7f5b4adb1408 <pg_bvarchar+136>: movzx eax,BYTE PTR
[rbx+0x1] - 0x7f5b4adb140c <pg_bvarchar+140>: cmp al,0x1 -
0x7f5b4adb140e <pg_bvarchar+142>: je 0x7f5b4adb1438 <pg_bvarchar+184> -
0x7f5b4adb1410 <pg_bvarchar+144>: mov edx,eax - 0x7f5b4adb1412
<pg_bvarchar+146>: and edx,0xfe - 0x7f5b4adb1418 <pg_bvarchar+152>: cmp
edx,0x2 - 0x7f5b4adb141b <pg_bvarchar+155>: je 0x7f5b4adb1438
<pg_bvarchar+184> - 0x7f5b4adb141d <pg_bvarchar+157>: cmp al,0x12 -
0x7f5b4adb141f <pg_bvarchar+159>: jne 0x7f5b4adb144e <pg_bvarchar+206> -
0x7f5b4adb1421 <pg_bvarchar+161>: mov r13d,0xc - 0x7f5b4adb1427
<pg_bvarchar+167>: mov r12d,0x40 - 0x7f5b4adb142d <pg_bvarchar+173>: mov
edi,0x10 - 0x7f5b4adb1432 <pg_bvarchar+178>: jmp 0x7f5b4adb13b4
<pg_bvarchar+52> - 0x7f5b4adb1434 <pg_bvarchar+180>: nop DWORD PTR
[rax+0x0] - 0x7f5b4adb1438 <pg_bvarchar+184>: mov r13d,0x4 -
0x7f5b4adb143e <pg_bvarchar+190>: mov r12d,0x20 - 0x7f5b4adb1444
<pg_bvarchar+196>: mov edi,0x8 - 0x7f5b4adb1449 <pg_bvarchar+201>: jmp
0x7f5b4adb13b4 <pg_bvarchar+52> - 0x7f5b4adb144e <pg_bvarchar+206>: mov
ecx,0x81 - 0x7f5b4adb1453 <pg_bvarchar+211>: lea rdx,[rip+0xba6] #
0x7f5b4adb2000 - 0x7f5b4adb145a <pg_bvarchar+218>: lea rsi,[rip+0xba9] #
0x7f5b4adb200a - 0x7f5b4adb1461 <pg_bvarchar+225>: lea rdi,[rip+0xbbc] #
0x7f5b4adb2024 - 0x7f5b4adb1468 <pg_bvarchar+232>: call 0x7f5b4adb1060
<ExceptionalCondition(at)plt> - 0x7f5b4adb146d: nop DWORD PTR [rax]
On 8.3.19. 20:15, Andrew Gierth wrote:
>>>>>> "gmail" == gmail Vladimir Koković <vladimir(dot)kokovic(at)gmail(dot)com> writes:
> gmail> VarChar *arg = PG_GETARG_VARCHAR_PP(0);
>
> The _PP there means that this is allowed to return either a packed
> (short) varlena or a normal one...
>
> gmail> len = VARSIZE( arg ) - VARHDRSZ;
>
> ...but VARSIZE is only allowed on unpacked varlenas, you need to use
> VARSIZE_ANY_EXHDR instead (and VARDATA_ANY rather than VARDATA).
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2019-03-09 09:48:24 | Re: BUG #15653: pg_detoast_datum_packed problem |
Previous Message | PG Bug reporting form | 2019-03-09 04:06:47 | BUG #15682: Change default value of checkpoint_completion_target to 0.9 for better performance? |