errors when there is a bit literal in ecpg

Started by Wang, Shenhaoover 5 years ago2 messageshackers
Jump to latest
#1Wang, Shenhao
wangsh.fnst@cn.fujitsu.com

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@lists.postgresql.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

Attachments:

0001-Fix-error-when-handle-bit-string.patchapplication/octet-stream; name=0001-Fix-error-when-handle-bit-string.patchDownload+299-9
a.pgcapplication/octet-stream; name=a.pgcDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Wang, Shenhao (#1)
Re: errors when there is a bit literal in ecpg

"Wang, Shenhao" <wangsh.fnst@cn.fujitsu.com> writes:

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@lists.postgresql.org>

Indeed. This has apparently been broken for a very long time (though
the "unreachable state" part is fairly new).

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.

I thought that a whole new test case was overkill when we could just add a
couple of lines to an existing test. Other than that, looks good, pushed.

regards, tom lane