mirror of
https://github.com/postgres/postgres.git
synced 2026-02-24 18:37:22 -05:00
While a self-referential view doesn't actually work, it's possible
to create one, and it turns out that this breaks some of the
information_schema views. Those views call relation_is_updatable(),
which neglected to consider the hazards of being recursive. In
older PG versions you get a "stack depth limit exceeded" error,
but since v10 it'd recurse to the point of stack overrun and crash,
because commit a4c35ea1c took out the expression_returns_set() call
that was incidentally checking the stack depth.
Since this function is only used by information_schema views, it
seems like it'd be better to return "not updatable" than suffer
an error. Hence, add tracking of what views we're examining,
in just the same way that the nearby fireRIRrules() code detects
self-referential views. I added a check_stack_depth() call too,
just to be defensive.
Per private report from Manuel Rigger. Back-patch to all
supported versions.
37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* rewriteHandler.h
|
|
* External interface to query rewriter.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/rewrite/rewriteHandler.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef REWRITEHANDLER_H
|
|
#define REWRITEHANDLER_H
|
|
|
|
#include "utils/relcache.h"
|
|
#include "nodes/parsenodes.h"
|
|
|
|
extern List *QueryRewrite(Query *parsetree);
|
|
extern void AcquireRewriteLocks(Query *parsetree,
|
|
bool forExecute,
|
|
bool forUpdatePushedDown);
|
|
|
|
extern Node *build_column_default(Relation rel, int attrno);
|
|
extern void rewriteTargetListUD(Query *parsetree, RangeTblEntry *target_rte,
|
|
Relation target_relation);
|
|
|
|
extern Query *get_view_query(Relation view);
|
|
extern const char *view_query_is_auto_updatable(Query *viewquery,
|
|
bool check_cols);
|
|
extern int relation_is_updatable(Oid reloid,
|
|
List *outer_reloids,
|
|
bool include_triggers,
|
|
Bitmapset *include_cols);
|
|
|
|
#endif /* REWRITEHANDLER_H */
|