errors when there is a bit literal in ecpg

From: "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: errors when there is a bit literal in ecpg
Date: 2020-11-06 22:56:11
Message-ID: d6402f1bacb74ecba22ef715dbba17fd@G08CNEXMBPEKD06.g08.fujitsu.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, hacker

I met an error as below when I use ecpg

a.pgc:5: ERROR: invalid bit string literal
a.pgc:5: ERROR: internal error: unreachable state; please report this to <pgsql-bugs(at)lists(dot)postgresql(dot)org>

the test source is attached.

After investigating the code, I think the process of pgc.l is:
Step 1: <SQL>{xbstart}, addlitchar('b') is called, literalbuf contains a char 'b';
Step 2: <xb>{xbinside}, the rest of char is added in literalbuf
Step 3: <xqs>{other}, the condition literalbuf[strspn(literalbuf, "01") + 1] != '\0' will always be true;
error is occurred here

I try to fix this bug by deleting 'addlitchar('b');' from source I also add a test case to test all const str in ecpg.

The patch is also attached.

Best regards, Shenhao Wang

Attachment Content-Type Size
0001-Fix-error-when-handle-bit-string.patch application/octet-stream 13.4 KB
a.pgc application/octet-stream 69 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2020-11-06 23:11:15 Re: Support for NSS as a libpq TLS backend
Previous Message John Naylor 2020-11-06 22:20:00 Re: speed up unicode decomposition and recomposition