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

Commitf9e4f61

Browse files
committed
First pass at set-returning-functions in FROM, by Joe Conway with
some kibitzing from Tom Lane. Not everything works yet, and there'sno documentation or regression test, but let's commit this so Joedoesn't need to cope with tracking changes in so many files ...
1 parent7100935 commitf9e4f61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1795
-311
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.18 2002/05/05 00:03:28 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.19 2002/05/12 20:10:01 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -492,7 +492,8 @@ FuncnameGetCandidates(List *names, int nargs)
492492
elog(ERROR,"Cross-database references are not implemented");
493493
break;
494494
default:
495-
elog(ERROR,"Improper qualified name (too many dotted names)");
495+
elog(ERROR,"Improper qualified name (too many dotted names): %s",
496+
NameListToString(names));
496497
break;
497498
}
498499

@@ -746,7 +747,8 @@ OpernameGetCandidates(List *names, char oprkind)
746747
elog(ERROR,"Cross-database references are not implemented");
747748
break;
748749
default:
749-
elog(ERROR,"Improper qualified name (too many dotted names)");
750+
elog(ERROR,"Improper qualified name (too many dotted names): %s",
751+
NameListToString(names));
750752
break;
751753
}
752754

@@ -1199,7 +1201,8 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
11991201
elog(ERROR,"Cross-database references are not implemented");
12001202
break;
12011203
default:
1202-
elog(ERROR,"Improper qualified name (too many dotted names)");
1204+
elog(ERROR,"Improper qualified name (too many dotted names): %s",
1205+
NameListToString(names));
12031206
break;
12041207
}
12051208

‎src/backend/commands/explain.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994-5, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.76 2002/05/03 15:56:45 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.77 2002/05/12 20:10:02 tgl Exp $
99
*
1010
*/
1111

@@ -262,6 +262,9 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
262262
caseT_SubqueryScan:
263263
pname="Subquery Scan";
264264
break;
265+
caseT_FunctionScan:
266+
pname="Function Scan";
267+
break;
265268
caseT_Material:
266269
pname="Materialize";
267270
break;
@@ -336,7 +339,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
336339
char*relname;
337340

338341
/* Assume it's on a real relation */
339-
Assert(rte->relid);
342+
Assert(rte->rtekind==RTE_RELATION);
340343

341344
/* We only show the rel name, not schema name */
342345
relname=get_rel_name(rte->relid);
@@ -358,6 +361,33 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
358361
quote_identifier(rte->eref->aliasname));
359362
}
360363
break;
364+
caseT_FunctionScan:
365+
if (((Scan*)plan)->scanrelid>0)
366+
{
367+
RangeTblEntry*rte=rt_fetch(((Scan*)plan)->scanrelid,
368+
es->rtable);
369+
Expr*expr;
370+
Func*funcnode;
371+
Oidfuncid;
372+
char*proname;
373+
374+
/* Assert it's on a RangeFunction */
375+
Assert(rte->rtekind==RTE_FUNCTION);
376+
377+
expr= (Expr*)rte->funcexpr;
378+
funcnode= (Func*)expr->oper;
379+
funcid=funcnode->funcid;
380+
381+
/* We only show the func name, not schema name */
382+
proname=get_func_name(funcid);
383+
384+
appendStringInfo(str," on %s",
385+
quote_identifier(proname));
386+
if (strcmp(rte->eref->aliasname,proname)!=0)
387+
appendStringInfo(str," %s",
388+
quote_identifier(rte->eref->aliasname));
389+
}
390+
break;
361391
default:
362392
break;
363393
}
@@ -397,6 +427,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
397427
break;
398428
caseT_SeqScan:
399429
caseT_TidScan:
430+
caseT_FunctionScan:
400431
show_scan_qual(plan->qual, false,
401432
"Filter",
402433
((Scan*)plan)->scanrelid,
@@ -545,7 +576,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
545576
es->rtable);
546577
List*saved_rtable=es->rtable;
547578

548-
Assert(rte->subquery!=NULL);
579+
Assert(rte->rtekind==RTE_SUBQUERY);
549580
es->rtable=rte->subquery->rtable;
550581

551582
for (i=0;i<indent;i++)
@@ -623,11 +654,7 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel,
623654
/* Generate deparse context */
624655
Assert(scanrelid>0&&scanrelid <=length(es->rtable));
625656
rte=rt_fetch(scanrelid,es->rtable);
626-
627-
/* Assume it's on a real relation */
628-
Assert(rte->relid);
629-
scancontext=deparse_context_for_relation(rte->eref->aliasname,
630-
rte->relid);
657+
scancontext=deparse_context_for_rte(rte);
631658

632659
/*
633660
* If we have an outer plan that is referenced by the qual, add it to

‎src/backend/commands/indexcmds.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.72 2002/04/27 03:45:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.73 2002/05/12 20:10:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -452,7 +452,8 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
452452
elog(ERROR,"Cross-database references are not implemented");
453453
break;
454454
default:
455-
elog(ERROR,"Improper opclass name (too many dotted names)");
455+
elog(ERROR,"Improper opclass name (too many dotted names): %s",
456+
NameListToString(attribute->opclass));
456457
break;
457458
}
458459

‎src/backend/executor/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for executor
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/executor/Makefile,v 1.17 2001/09/18 01:59:06 tgl Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/executor/Makefile,v 1.18 2002/05/12 20:10:02 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,9 +16,9 @@ OBJS = execAmi.o execFlatten.o execJunk.o execMain.o \
1616
execProcnode.o execQual.o execScan.o execTuples.o\
1717
execUtils.o functions.o instrument.o nodeAppend.o nodeAgg.o nodeHash.o\
1818
nodeHashjoin.o nodeIndexscan.o nodeMaterial.o nodeMergejoin.o\
19-
nodeNestloop.onodeResult.onodeSeqscan.onodeSetOp.o nodeSort.o\
20-
nodeUnique.onodeLimit.onodeGroup.onodeSubplan.o\
21-
nodeSubqueryscan.o nodeTidscan.o spi.o
19+
nodeNestloop.onodeFunctionscan.onodeResult.onodeSeqscan.o\
20+
nodeSetOp.onodeSort.onodeUnique.onodeLimit.o nodeGroup.o\
21+
nodeSubplan.onodeSubqueryscan.o nodeTidscan.o spi.o
2222

2323
all: SUBSYS.o
2424

‎src/backend/executor/execAmi.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Id: execAmi.c,v 1.62 2002/03/02 21:39:24 momjian Exp $
9+
*$Id: execAmi.c,v 1.63 2002/05/12 20:10:02 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -35,6 +35,7 @@
3535
#include"executor/nodeSort.h"
3636
#include"executor/nodeSubplan.h"
3737
#include"executor/nodeSubqueryscan.h"
38+
#include"executor/nodeFunctionscan.h"
3839
#include"executor/nodeUnique.h"
3940

4041

@@ -100,6 +101,10 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
100101
ExecSubqueryReScan((SubqueryScan*)node,exprCtxt,parent);
101102
break;
102103

104+
caseT_FunctionScan:
105+
ExecFunctionReScan((FunctionScan*)node,exprCtxt,parent);
106+
break;
107+
103108
caseT_Material:
104109
ExecMaterialReScan((Material*)node,exprCtxt,parent);
105110
break;
@@ -187,6 +192,10 @@ ExecMarkPos(Plan *node)
187192
ExecIndexMarkPos((IndexScan*)node);
188193
break;
189194

195+
caseT_FunctionScan:
196+
ExecFunctionMarkPos((FunctionScan*)node);
197+
break;
198+
190199
caseT_Material:
191200
ExecMaterialMarkPos((Material*)node);
192201
break;
@@ -229,6 +238,10 @@ ExecRestrPos(Plan *node)
229238
ExecIndexRestrPos((IndexScan*)node);
230239
break;
231240

241+
caseT_FunctionScan:
242+
ExecFunctionRestrPos((FunctionScan*)node);
243+
break;
244+
232245
caseT_Material:
233246
ExecMaterialRestrPos((Material*)node);
234247
break;

‎src/backend/executor/execMain.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
*
2929
* IDENTIFICATION
30-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.160 2002/04/27 21:24:34 tgl Exp $
30+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.161 2002/05/12 20:10:02 tgl Exp $
3131
*
3232
*-------------------------------------------------------------------------
3333
*/
@@ -311,7 +311,7 @@ ExecCheckPlanPerms(Plan *plan, List *rangeTable, CmdType operation)
311311

312312
/* Recursively check the subquery */
313313
rte=rt_fetch(scan->scan.scanrelid,rangeTable);
314-
Assert(rte->subquery!=NULL);
314+
Assert(rte->rtekind==RTE_SUBQUERY);
315315
ExecCheckQueryPerms(operation,rte->subquery,scan->subplan);
316316
break;
317317
}
@@ -362,10 +362,12 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation)
362362
Oiduserid;
363363
AclResultaclcheck_result;
364364

365-
/*
366-
* If it's a subquery RTE, ignore it --- it will be checked when
367-
* ExecCheckPlanPerms finds the SubqueryScan node for it.
368-
*/
365+
/*
366+
* Only plain-relation RTEs need to be checked here. Subquery RTEs
367+
* will be checked when ExecCheckPlanPerms finds the SubqueryScan node,
368+
* and function RTEs are checked by init_fcache when the function is
369+
* prepared for execution. Join and special RTEs need no checks.
370+
*/
369371
if (rte->rtekind!=RTE_RELATION)
370372
return;
371373

‎src/backend/executor/execProcnode.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.28 2001/10/25 05:49:27 momjian Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.29 2002/05/12 20:10:02 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -96,6 +96,7 @@
9696
#include"executor/nodeSort.h"
9797
#include"executor/nodeSubplan.h"
9898
#include"executor/nodeSubqueryscan.h"
99+
#include"executor/nodeFunctionscan.h"
99100
#include"executor/nodeUnique.h"
100101
#include"miscadmin.h"
101102
#include"tcop/tcopprot.h"
@@ -168,6 +169,11 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent)
168169
parent);
169170
break;
170171

172+
caseT_FunctionScan:
173+
result=ExecInitFunctionScan((FunctionScan*)node,estate,
174+
parent);
175+
break;
176+
171177
/*
172178
* join nodes
173179
*/
@@ -297,6 +303,10 @@ ExecProcNode(Plan *node, Plan *parent)
297303
result=ExecSubqueryScan((SubqueryScan*)node);
298304
break;
299305

306+
caseT_FunctionScan:
307+
result=ExecFunctionScan((FunctionScan*)node);
308+
break;
309+
300310
/*
301311
* join nodes
302312
*/
@@ -392,6 +402,9 @@ ExecCountSlotsNode(Plan *node)
392402
caseT_SubqueryScan:
393403
returnExecCountSlotsSubqueryScan((SubqueryScan*)node);
394404

405+
caseT_FunctionScan:
406+
returnExecCountSlotsFunctionScan((FunctionScan*)node);
407+
395408
/*
396409
* join nodes
397410
*/
@@ -503,6 +516,10 @@ ExecEndNode(Plan *node, Plan *parent)
503516
ExecEndSubqueryScan((SubqueryScan*)node);
504517
break;
505518

519+
caseT_FunctionScan:
520+
ExecEndFunctionScan((FunctionScan*)node);
521+
break;
522+
506523
/*
507524
* join nodes
508525
*/
@@ -640,6 +657,14 @@ ExecGetTupType(Plan *node)
640657
}
641658
break;
642659

660+
caseT_FunctionScan:
661+
{
662+
CommonScanState*scanstate= ((FunctionScan*)node)->scan.scanstate;
663+
664+
slot=scanstate->cstate.cs_ResultTupleSlot;
665+
}
666+
break;
667+
643668
caseT_Material:
644669
{
645670
MaterialState*matstate= ((Material*)node)->matstate;

‎src/backend/executor/execQual.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.91 2002/04/27 03:45:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.92 2002/05/12 20:10:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -700,6 +700,7 @@ ExecMakeFunctionResult(FunctionCachePtr fcache,
700700
{
701701
fcinfo.resultinfo= (Node*)&rsinfo;
702702
rsinfo.type=T_ReturnSetInfo;
703+
rsinfo.econtext=econtext;
703704
}
704705

705706
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp