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

Commitf93b697

Browse files
committed
Here's a combination of all the patches I'm currently waiting
for against a just updated CVS tree. It contains Partial new rewrite system that handles subselects, view aggregate columns, insert into select from view, updates with set col = view-value and select rules restriction to view definition. Updates for rule/view backparsing utility functions to handle subselects correct. New system views pg_tables and pg_indexes (where you can see the complete index definition in the latter one). Enabling array references on query parameters. Bugfix for functional index. Little changes to system views pg_rules and pg_views. The rule system isn't a release-stopper any longer. But another stopper is that I don't know if the latest changes to PL/pgSQL (not already in CVS) made it compile on AIX. Still wait for some response from Dave.Jan
1 parent9b21a18 commitf93b697

File tree

11 files changed

+3164
-661
lines changed

11 files changed

+3164
-661
lines changed

‎src/backend/access/index/indexam.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.27 1998/09/07 05:35:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.28 1998/10/02 16:27:43 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*index_open- open an index relation by relationId
@@ -362,7 +362,7 @@ GetIndexValue(HeapTuple tuple,
362362
bool*attNull)
363363
{
364364
DatumreturnVal;
365-
boolisNull;
365+
boolisNull= FALSE;
366366

367367
if (PointerIsValid(fInfo)&&FIgetProcOid(fInfo)!=InvalidOid)
368368
{
@@ -375,13 +375,15 @@ GetIndexValue(HeapTuple tuple,
375375
attrNums[i],
376376
hTupDesc,
377377
attNull);
378+
if (*attNull)
379+
isNull= TRUE;
378380
}
379381
returnVal= (Datum)fmgr_array_args(FIgetProcOid(fInfo),
380382
FIgetnArgs(fInfo),
381383
(char**)attData,
382384
&isNull);
383385
pfree(attData);
384-
*attNull=FALSE;
386+
*attNull=isNull;
385387
}
386388
else
387389
returnVal=heap_getattr(tuple,attrNums[attOff],hTupDesc,attNull);

‎src/backend/rewrite/locks.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.13 1998/09/01 04:31:30 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.14 1998/10/02 16:27:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -24,7 +24,6 @@
2424
#include"utils/builtins.h"
2525
#include"catalog/pg_shadow.h"
2626

27-
staticvoidcheckLockPerms(List*locks,Query*parsetree,intrt_index);
2827

2928
/*
3029
* ThisLockWasTriggered
@@ -170,7 +169,7 @@ matchLocks(CmdType event,
170169
}
171170

172171

173-
staticvoid
172+
void
174173
checkLockPerms(List*locks,Query*parsetree,intrt_index)
175174
{
176175
Relationev_rel;

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.21 1998/09/01 04:31:32 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.22 1998/10/02 16:27:46 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -199,11 +199,8 @@ DefineQueryRewrite(RuleStmt *stmt)
199199
/* ----------
200200
* The current rewrite handler is known to work on relation level
201201
* rules only. And for SELECT events, it expects one non-nothing
202-
* action that is instead. Since we now hand out views and rules
203-
* to regular users, we must deny anything else.
204-
*
205-
* I know that I must write a new rewrite handler from scratch
206-
* for 6.5 so we can remove these checks and allow all the rules.
202+
* action that is instead and returns exactly a tuple of the
203+
* rewritten relation. This restricts SELECT rules to views.
207204
*
208205
* Jan
209206
* ----------
@@ -217,6 +214,9 @@ DefineQueryRewrite(RuleStmt *stmt)
217214
else
218215
eslot_string=NULL;
219216

217+
/*
218+
* No rule actions that modify OLD or NEW
219+
*/
220220
if (action!=NIL)
221221
foreach(l,action)
222222
{
@@ -233,23 +233,86 @@ DefineQueryRewrite(RuleStmt *stmt)
233233
}
234234
}
235235

236+
/*
237+
* Rules ON SELECT are restricted to view definitions
238+
*/
236239
if (event_type==CMD_SELECT)
237240
{
241+
TargetEntry*tle;
242+
Resdom*resdom;
243+
Form_pg_attributeattr;
244+
char*attname;
245+
inti;
246+
247+
/*
248+
* So there cannot be INSTEAD NOTHING, ...
249+
*/
238250
if (length(action)==0)
239251
{
240252
elog(NOTICE,"instead nothing rules on select currently not supported");
241253
elog(ERROR," use views instead");
242254
}
255+
256+
/*
257+
* ... there cannot be multiple actions, ...
258+
*/
243259
if (length(action)>1)
244260
elog(ERROR,"multiple action rules on select currently not supported");
261+
/*
262+
* ... the one action must be a SELECT, ...
263+
*/
245264
query= (Query*)lfirst(action);
246265
if (!is_instead||query->commandType!=CMD_SELECT)
247266
elog(ERROR,"only instead-select rules currently supported on select");
267+
if (event_qual!=NULL)
268+
elog(ERROR,"event qualifications not supported for rules on select");
269+
270+
/*
271+
* ... the targetlist of the SELECT action must
272+
* exactly match the event relation ...
273+
*/
274+
event_relation=heap_openr(event_obj->relname);
275+
if (event_relation==NULL)
276+
elog(ERROR,"virtual relations not supported yet");
277+
278+
if (event_relation->rd_att->natts!=length(query->targetList))
279+
elog(ERROR,"select rules target list must match event relations structure");
280+
281+
for (i=1;i <=event_relation->rd_att->natts;i++) {
282+
tle= (TargetEntry*)nth(i-1,query->targetList);
283+
resdom=tle->resdom;
284+
attr=event_relation->rd_att->attrs[i-1];
285+
attname=nameout(&(attr->attname));
286+
287+
if (strcmp(resdom->resname,attname)!=0)
288+
elog(ERROR,"select rules target entry %d has different column name from %s",i,attname);
289+
290+
if (attr->atttypid!=resdom->restype)
291+
elog(ERROR,"select rules target entry %d has different type from attribute %s",i,attname);
292+
293+
if (attr->atttypmod!=resdom->restypmod)
294+
elog(ERROR,"select rules target entry %d has different size from attribute %s",i,attname);
295+
}
296+
297+
/*
298+
* ... and final there must not be another ON SELECT
299+
* rule already.
300+
*/
301+
if (event_relation->rd_rules!=NULL) {
302+
for (i=0;i<event_relation->rd_rules->numLocks;i++) {
303+
RewriteRule*rule;
304+
305+
rule=event_relation->rd_rules->rules[i];
306+
if (rule->event==CMD_SELECT)
307+
elog(ERROR,"%s is already a view",nameout(&(event_relation->rd_rel->relname)));
308+
}
309+
}
310+
311+
heap_close(event_relation);
248312
}
249313

250314
/*
251-
* This rule is currently allowed - too restricted I know - but women
252-
* and children first Jan
315+
* This rule is allowed - install it.
253316
*/
254317

255318
event_relation=heap_openr(event_obj->relname);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp