Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cb1a5a

Browse files
committed
Fix reading of BitString nodes
The node tokenizer went out of its way to store BitString node valueswithout the leading 'b'. But everything else in the system stores theleading 'b'. This would break if a BitString node isread-printed-read.Also, the node tokenizer didn't know that BitString node tokens couldalso start with 'x'.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/4159834.1657405226@sss.pgh.pa.us
1 parent43f4b34 commit2cb1a5a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

‎src/backend/nodes/read.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ nodeTokenType(const char *token, int length)
288288
retval=T_Boolean;
289289
elseif (*token=='"'&&length>1&&token[length-1]=='"')
290290
retval=T_String;
291-
elseif (*token=='b')
291+
elseif (*token=='b'||*token=='x')
292292
retval=T_BitString;
293293
else
294294
retval=OTHER_TOKEN;
@@ -471,11 +471,10 @@ nodeRead(const char *token, int tok_len)
471471
break;
472472
caseT_BitString:
473473
{
474-
char*val=palloc(tok_len);
474+
char*val=palloc(tok_len+1);
475475

476-
/* skip leading 'b' */
477-
memcpy(val,token+1,tok_len-1);
478-
val[tok_len-1]='\0';
476+
memcpy(val,token,tok_len);
477+
val[tok_len]='\0';
479478
result= (Node*)makeBitString(val);
480479
break;
481480
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp