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

Commit49eb0fd

Browse files
committed
Add location field to DefElem
Add a location field to the DefElem struct, used to parse many utilitycommands. Update various error messages to supply error positioninformation.To propogate the error position information in a more systematic way,create a ParseState in standard_ProcessUtility() and pass that tointerested functions implementing the utility commands. This seemsbetter than passing the query string and then reassembling a parse statead hoc, which violates the encapsulation of the ParseState type.Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
1 parent975768f commit49eb0fd

38 files changed

+438
-347
lines changed

‎contrib/file_fdw/file_fdw.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ file_fdw_validator(PG_FUNCTION_ARGS)
293293
/*
294294
* Now apply the core COPY code's validation logic for more checks.
295295
*/
296-
ProcessCopyOptions(NULL, true,other_options);
296+
ProcessCopyOptions(NULL,NULL,true,other_options);
297297

298298
/*
299299
* Filename option is required for file_fdw foreign tables.
@@ -455,10 +455,10 @@ get_file_fdw_attribute_options(Oid relid)
455455
* force_null options set
456456
*/
457457
if (fnncolumns!=NIL)
458-
options=lappend(options,makeDefElem("force_not_null", (Node*)fnncolumns));
458+
options=lappend(options,makeDefElem("force_not_null", (Node*)fnncolumns,-1));
459459

460460
if (fncolumns!=NIL)
461-
options=lappend(options,makeDefElem("force_null", (Node*)fncolumns));
461+
options=lappend(options,makeDefElem("force_null", (Node*)fncolumns,-1));
462462

463463
returnoptions;
464464
}
@@ -511,7 +511,7 @@ fileGetForeignPaths(PlannerInfo *root,
511511
foreigntableid,
512512
&columns))
513513
coptions=list_make1(makeDefElem("convert_selectively",
514-
(Node*)columns));
514+
(Node*)columns,-1));
515515

516516
/* Estimate costs */
517517
estimate_costs(root,baserel,fdw_private,
@@ -632,7 +632,8 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
632632
* Create CopyState from FDW options. We always acquire all columns, so
633633
* as to match the expected ScanTupleSlot signature.
634634
*/
635-
cstate=BeginCopyFrom(node->ss.ss_currentRelation,
635+
cstate=BeginCopyFrom(NULL,
636+
node->ss.ss_currentRelation,
636637
filename,
637638
false,
638639
NIL,
@@ -705,7 +706,8 @@ fileReScanForeignScan(ForeignScanState *node)
705706

706707
EndCopyFrom(festate->cstate);
707708

708-
festate->cstate=BeginCopyFrom(node->ss.ss_currentRelation,
709+
festate->cstate=BeginCopyFrom(NULL,
710+
node->ss.ss_currentRelation,
709711
festate->filename,
710712
false,
711713
NIL,
@@ -1053,7 +1055,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
10531055
/*
10541056
* Create CopyState from FDW options.
10551057
*/
1056-
cstate=BeginCopyFrom(onerel,filename, false,NIL,options);
1058+
cstate=BeginCopyFrom(NULL,onerel,filename, false,NIL,options);
10571059

10581060
/*
10591061
* Use per-tuple memory context to prevent leak of memory used to read

‎src/backend/access/common/reloptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ untransformRelOptions(Datum options)
888888
*p++='\0';
889889
val= (Node*)makeString(pstrdup(p));
890890
}
891-
result=lappend(result,makeDefElem(pstrdup(s),val));
891+
result=lappend(result,makeDefElem(pstrdup(s),val,-1));
892892
}
893893

894894
returnresult;

‎src/backend/catalog/aclchk.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
849849
* ALTER DEFAULT PRIVILEGES statement
850850
*/
851851
void
852-
ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt*stmt)
852+
ExecAlterDefaultPrivilegesStmt(ParseState*pstate,AlterDefaultPrivilegesStmt*stmt)
853853
{
854854
GrantStmt*action=stmt->action;
855855
InternalDefaultACLiacls;
@@ -871,15 +871,17 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
871871
if (dnspnames)
872872
ereport(ERROR,
873873
(errcode(ERRCODE_SYNTAX_ERROR),
874-
errmsg("conflicting or redundant options")));
874+
errmsg("conflicting or redundant options"),
875+
parser_errposition(pstate,defel->location)));
875876
dnspnames=defel;
876877
}
877878
elseif (strcmp(defel->defname,"roles")==0)
878879
{
879880
if (drolespecs)
880881
ereport(ERROR,
881882
(errcode(ERRCODE_SYNTAX_ERROR),
882-
errmsg("conflicting or redundant options")));
883+
errmsg("conflicting or redundant options"),
884+
parser_errposition(pstate,defel->location)));
883885
drolespecs=defel;
884886
}
885887
else

‎src/backend/commands/aggregatecmds.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
* "parameters" is a list of DefElem representing the agg's definition clauses.
5353
*/
5454
ObjectAddress
55-
DefineAggregate(List*name,List*args,boololdstyle,List*parameters,
56-
constchar*queryString)
55+
DefineAggregate(ParseState*pstate,List*name,List*args,boololdstyle,List*parameters)
5756
{
5857
char*aggName;
5958
OidaggNamespace;
@@ -287,10 +286,10 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters,
287286
errmsg("basetype is redundant with aggregate input type specification")));
288287

289288
numArgs=list_length(args);
290-
interpret_function_parameter_list(args,
289+
interpret_function_parameter_list(pstate,
290+
args,
291291
InvalidOid,
292292
true,/* is an aggregate */
293-
queryString,
294293
&parameterTypes,
295294
&allParameterTypes,
296295
&parameterModes,

‎src/backend/commands/collationcmds.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* CREATE COLLATION
3939
*/
4040
ObjectAddress
41-
DefineCollation(List*names,List*parameters)
41+
DefineCollation(ParseState*pstate,List*names,List*parameters)
4242
{
4343
char*collName;
4444
OidcollNamespace;
@@ -78,7 +78,8 @@ DefineCollation(List *names, List *parameters)
7878
ereport(ERROR,
7979
(errcode(ERRCODE_SYNTAX_ERROR),
8080
errmsg("collation attribute \"%s\" not recognized",
81-
defel->defname)));
81+
defel->defname),
82+
parser_errposition(pstate,defel->location)));
8283
break;
8384
}
8485

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp