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

Commit7666e73

Browse files
committed
Throw an error if a DATA() line contains wrong # of attributes.
David Christensen, reviewed by Dagfinn Ilmari MannsåkerDiscussion:http://postgr.es/m/20170215154018.fs5vwtqhp5d2sifs@veeddeux.attlocal.net
1 parentccce90b commit7666e73

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ sub Catalogs
4646

4747
open(INPUT_FILE,'<',$input_file) ||die"$input_file:$!";
4848

49+
my ($filename) = ($input_file =~m/(\w+)\.h$/);
50+
my$natts_pat ="Natts_$filename";
51+
4952
# Scan the input file.
5053
while (<INPUT_FILE>)
5154
{
@@ -70,8 +73,15 @@ sub Catalogs
7073
s/\s+//g;
7174

7275
# Push the data into the appropriate data structure.
73-
if (/^DATA\(insert(\s+OID\s+=\s+(\d+))?\s+\(\s*(.*)\s*\)\s*\)$/)
76+
if (/$natts_pat\s+(\d+)/)
77+
{
78+
$catalog{natts} =$1;
79+
}
80+
elsif (/^DATA\(insert(\s+OID\s+=\s+(\d+))?\s+\(\s*(.*)\s*\)\s*\)$/)
7481
{
82+
check_natts($filename,$catalog{natts},$3,
83+
$input_file, INPUT_FILE->input_line_number);
84+
7585
push @{$catalog{data} }, {oid=>$2,bki_values=>$3 };
7686
}
7787
elsif (/^DESCR\(\"(.*)\"\)$/)
@@ -216,4 +226,20 @@ sub RenameTempFile
216226
rename($temp_name,$final_name) ||die"rename:$temp_name:$!";
217227
}
218228

229+
# verify the number of fields in the passed-in bki structure
230+
subcheck_natts
231+
{
232+
my ($catname,$natts,$bki_val,$file,$line) =@_;
233+
die"Could not find definition for Natts_${catname} before start of DATA() in$file\n"
234+
unlessdefined$natts;
235+
236+
# we're working with a copy and need to count the fields only, so collapse
237+
$bki_val =~s/"[^"]*?"/xxx/g;
238+
my@atts =split /\s+/,$bki_val;
239+
240+
diesprintf
241+
"Wrong number of attributes in DATA() entry at%s:%d (expected%d but got%d)\n",
242+
$file,$line,$natts,scalar@atts
243+
unless$natts ==@atts;
244+
}
219245
1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp