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

Commite90d4dd

Browse files
committed
Simplify genbki.pl's data quoting rules.
During the bootstrap data format conversion, it seemed important forverifiability's sake that the generated postgres.bki file stayed the sameas before. That resulted in adding a bunch of ad-hoc rules about when toquote emitted data values, to match previous manual decisions that hadoften quoted values unnecessarily. Now that the conversion is complete,it seems fine to remove all those ad-hoc rules. The net actual effect onthe current contents of postgres.bki is that some fields that had beenquoted despite containing only digits or only "-" lose their unnecessaryquotes.Also, now that genbki.pl will always quote values containing a backslash,there's no need for bootscanner.l to allow unquoted octal escapes;so simplify its production for "id" by removing that possibility.John Naylor, slightly modified by meDiscussion:https://postgr.es/m/CAJVSVGUNao=-Q2-vAN3PYcdF5tnL5JAHwGwzZGuYHtq+Mk_9ng@mail.gmail.com
1 parentcf5a189 commite90d4dd

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

‎src/backend/bootstrap/bootscanner.l

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static intyyline = 1;/* line number for error reporting */
6666

6767

6868
D[0-9]
69-
oct\\{D}{D}{D}
70-
id([A-Za-z0-9_]|{oct}|\-)+
69+
id[-A-Za-z0-9_]+
7170
sid\"([^\"])*\"
7271
arrayid [A-Za-z0-9_]+\[{D}*\]
7372

‎src/backend/catalog/genbki.pl

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,7 @@ sub morph_row_for_pgattr
645645
Catalog::AddDefaultValues($row,$pgattr_schema,'pg_attribute');
646646
}
647647

648-
# Write an entry to postgres.bki. Adding quotes here allows us to keep
649-
# most double quotes out of the catalog data files for readability. See
650-
# bootscanner.l for what tokens need quoting.
648+
# Write an entry to postgres.bki.
651649
subprint_bki_insert
652650
{
653651
my$row =shift;
@@ -666,26 +664,12 @@ sub print_bki_insert
666664
# since that represents a NUL char in C code.
667665
$bki_value =''if$bki_valueeq'\0';
668666

667+
# Quote value if needed. We need not quote values that satisfy
668+
# the "id" pattern in bootscanner.l, currently "[-A-Za-z0-9_]+".
669669
$bki_value =sprintf(qq'"%s"',$bki_value)
670-
if$bki_valuene'_null_'
671-
and$bki_value !~/^"[^"]+"$/
672-
and (length($bki_value) == 0# Empty string
673-
or$bki_value =~/\s/# Contains whitespace
674-
675-
# To preserve historical formatting, operator names are
676-
# always quoted. Likewise for values of multi-element types,
677-
# even if they only contain a single element.
678-
or$attnameeq'oprname'
679-
or$atttypeeq'oidvector'
680-
or$atttypeeq'int2vector'
681-
or$atttype =~/\[\]$/
682-
683-
# Quote strings that have non-word characters. We make
684-
# exceptions for values that are octals or negative numbers,
685-
# for the same historical reason as above.
686-
or ($bki_value =~/\W/
687-
and$bki_value !~/^\\\d{3}$/
688-
and$bki_value !~/^-\d*$/));
670+
if$bki_value !~/^"[^"]+"$/
671+
and (length($bki_value) == 0
672+
or$bki_value =~/[^-A-Za-z0-9_]/);
689673

690674
push@bki_values,$bki_value;
691675
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp