- linkend="sql-set-transaction" endterm="sql-set-transaction-title">
- command. If no isolation level is specified, the default isolation
- level is used.
-
-
-
Compatibility
-
-
SQL99
-
- is the default isolation level in
-
SQL99, but it is not the usual default in
-
PostgreSQL: the factory default setting
- is READ COMMITTED.
- does not provide the isolation levels
- and . Because of lack of predicate
- locking, the level is
- not truly serializable. See the User's Guide
- for details.
-
-
- In
SQL99 this statement can specify two other
- properties of the new transaction: whether the transaction is
- read-only and the size of the diagnostics area. Neither of these
- concepts are currently supported in
-
-
+ SQL99; but see also the compatibility section of
+ linkend="sql-set-transaction" endterm="sql-set-transaction-title">.
+
ON COMMIT options for temp tables
extra_float_digits option allows pg_dump to dump float data accurately
Long options for psql and pg_dump are now available on all platforms
+Read-only transactions
]]>
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.140 2002/11/23 03:59:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.141 2003/01/10 22:03:27 petere Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
int DefaultXactIsoLevel = XACT_READ_COMMITTED;
int XactIsoLevel;
+bool DefaultXactReadOnly = false;
+bool XactReadOnly;
+
bool autocommit = true;
int CommitDelay = 0; /* precommit delay in microseconds */
FreeXactSnapshot();
XactIsoLevel = DefaultXactIsoLevel;
+ XactReadOnly = DefaultXactReadOnly;
/*
* Check the current transaction state. If the transaction system is
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.43 2003/01/07 20:56:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.44 2003/01/10 22:03:27 petere Exp $
*
*-------------------------------------------------------------------------
*/
return InvalidOid;
}
+/*
+ * RelidGetNamespaceId
+ * Given a relation OID, return the namespace OID.
+ */
+Oid
+RelidGetNamespaceId(Oid relid)
+{
+ HeapTuple tuple;
+ Form_pg_class pg_class_form;
+ Oid result;
+
+ tuple = SearchSysCache(RELOID,
+ ObjectIdGetDatum(relid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "cache lookup failed for relation %u", relid);
+ pg_class_form = (Form_pg_class) GETSTRUCT(tuple);
+
+ result = pg_class_form->relnamespace;
+ ReleaseSysCache(tuple);
+ return result;
+}
+
+
/*
* RelationIsVisible
* Determine whether a relation (identified by OID) is visible in the
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.187 2002/12/15 16:17:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.188 2003/01/10 22:03:27 petere Exp $
*
*-------------------------------------------------------------------------
*/
*/
rel = heap_openrv(relation, (is_from ? RowExclusiveLock : AccessShareLock));
+ /* check read-only transaction */
+ if (XactReadOnly && !is_from && !isTempNamespace(RelationGetNamespace(rel)))
+ elog(ERROR, "transaction is read-only");
+
/* Check permissions. */
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
required_access);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.196 2003/01/08 23:32:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.197 2003/01/10 22:03:27 petere Exp $
*
*-------------------------------------------------------------------------
*/
static TupleTableSlot *EvalPlanQualNext(EState *estate);
static void EndEvalPlanQual(EState *estate);
static void ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation);
+static void ExecCheckXactReadOnly(Query *parsetree, CmdType operation);
static void EvalPlanQualStart(evalPlanQual *epq, EState *estate,
evalPlanQual *priorepq);
static void EvalPlanQualStop(evalPlanQual *epq);
operation = queryDesc->operation;
dest = queryDesc->dest;
+ /*
+ * If the transaction is read-only, we need to check if any writes
+ * are planned to non-temporary tables. This is done here at this
+ * rather late stage so that we can handle EXPLAIN vs. EXPLAIN
+ * ANALYZE easily.
+ */
+ ExecCheckXactReadOnly(queryDesc->parsetree, operation);
+
/*
* startup tuple receiver
*/
*/
+static void
+ExecCheckXactReadOnly(Query *parsetree, CmdType operation)
+{
+ if (!XactReadOnly)
+ return;
+
+ /* CREATE TABLE AS or SELECT INTO */
+ if (operation == CMD_SELECT && parsetree->into != NULL)
+ goto fail;
+
+ if (operation == CMD_DELETE || operation == CMD_INSERT
+ || operation == CMD_UPDATE)
+ {
+ List *lp;
+
+ foreach(lp, parsetree->rtable)
+ {
+ RangeTblEntry *rte = lfirst(lp);
+
+ if (rte->rtekind != RTE_RELATION)
+ continue;
+
+ if (!rte->checkForWrite)
+ continue;
+
+ if (isTempNamespace(RelidGetNamespaceId(rte->relid)))
+ continue;
+
+ goto fail;
+ }
+ }
+
+ return;
+
+fail:
+ elog(ERROR, "transaction is read-only");
+}
+
+
/* ----------------------------------------------------------------
* InitPlan
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.394 2003/01/10 21:08:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.395 2003/01/10 22:03:27 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
%type createdb_opt_item copy_opt_item
%type opt_lock lock_type cast_context
-%type opt_force opt_or_replace
+%type opt_force opt_or_replace transaction_access_mode
%type user_list
target_list update_target_list insert_column_list
insert_target_list def_list opt_indirection
group_clause TriggerFuncArgs select_limit
- opt_select_limit opclass_item_list trans_options
+ opt_select_limit opclass_item_list transaction_mode_list
+ transaction_mode_list_or_empty
TableFuncElementList
prep_type_clause prep_type_list
execute_param_clause
n->args = makeList1($3);
$$ = n;
}
- | TRANSACTION ISOLATION LEVEL iso_level opt_mode
+ | TRANSACTION transaction_mode_list
{
VariableSetStmt *n = makeNode(VariableSetStmt);
- n->name = "TRANSACTION ISOLATION LEVEL";
- n->args = makeList1(makeStringConst($4, NULL));
+ n->name = "TRANSACTION";
+ n->args = $2;
$$ = n;
}
- | SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL iso_level
+ | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
{
VariableSetStmt *n = makeNode(VariableSetStmt);
- n->name = "default_transaction_isolation";
- n->args = makeList1(makeStringConst($7, NULL));
+ n->name = "SESSION CHARACTERISTICS";
+ n->args = $5;
$$ = n;
}
| NAMES opt_encoding
| SERIALIZABLE { $$ = "serializable"; }
;
-opt_mode: READ WRITE
- {}
- | READ ONLY
- {
- elog(ERROR, "SET TRANSACTION/READ ONLY not yet supported");
- }
- | /*EMPTY*/
- {}
- ;
-
opt_boolean:
TRUE_P { $$ = "true"; }
| FALSE_P { $$ = "false"; }
| SHOW TRANSACTION ISOLATION LEVEL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
- n->name = "TRANSACTION ISOLATION LEVEL";
+ n->name = "transaction_isolation";
$$ = (Node *) n;
}
| SHOW SESSION AUTHORIZATION
| RESET TRANSACTION ISOLATION LEVEL
{
VariableResetStmt *n = makeNode(VariableResetStmt);
- n->name = "TRANSACTION ISOLATION LEVEL";
+ n->name = "transaction_isolation";
$$ = (Node *) n;
}
| RESET SESSION AUTHORIZATION
*****************************************************************************/
TransactionStmt:
- ABORT_TRANS opt_trans
+ ABORT_TRANS opt_transaction
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = ROLLBACK;
n->options = NIL;
$$ = (Node *)n;
}
- | BEGIN_TRANS opt_trans
+ | BEGIN_TRANS opt_transaction
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = BEGIN_TRANS;
n->options = NIL;
$$ = (Node *)n;
}
- | START TRANSACTION trans_options
+ | START TRANSACTION transaction_mode_list_or_empty
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = START;
n->options = $3;
$$ = (Node *)n;
}
- | COMMIT opt_trans
+ | COMMIT opt_transaction
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = COMMIT;
n->options = NIL;
$$ = (Node *)n;
}
- | END_TRANS opt_trans
+ | END_TRANS opt_transaction
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = COMMIT;
n->options = NIL;
$$ = (Node *)n;
}
- | ROLLBACK opt_trans
+ | ROLLBACK opt_transaction
{
TransactionStmt *n = makeNode(TransactionStmt);
n->command = ROLLBACK;
}
;
-trans_options: ISOLATION LEVEL iso_level
- { $$ = makeList1(makeStringConst($3, NULL)); }
- | /* EMPTY */ { $$ = NIL; }
- ;
-
-opt_trans: WORK {}
+opt_transaction: WORK {}
| TRANSACTION {}
| /*EMPTY*/ {}
;
+transaction_mode_list:
+ ISOLATION LEVEL iso_level
+ { $$ = makeList1(makeDefElem("transaction_isolation",
+ makeStringConst($3, NULL))); }
+ | transaction_access_mode
+ { $$ = makeList1(makeDefElem("transaction_read_only",
+ makeIntConst($1))); }
+ | ISOLATION LEVEL iso_level transaction_access_mode
+ {
+ $$ = makeList2(makeDefElem("transaction_isolation",
+ makeStringConst($3, NULL)),
+ makeDefElem("transaction_read_only",
+ makeIntConst($4)));
+ }
+ | transaction_access_mode ISOLATION LEVEL iso_level
+ {
+ $$ = makeList2(makeDefElem("transaction_read_only",
+ makeIntConst($1)),
+ makeDefElem("transaction_isolation",
+ makeStringConst($4, NULL)));
+ }
+ ;
+
+transaction_mode_list_or_empty:
+ transaction_mode_list
+ | /* EMPTY */
+ { $$ = NIL; }
+ ;
+
+transaction_access_mode:
+ READ ONLY { $$ = TRUE; }
+ | READ WRITE { $$ = FALSE; }
+ ;
+
+
/*****************************************************************************
*
* QUERY:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.188 2003/01/06 00:31:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.189 2003/01/10 22:03:28 petere Exp $
*
*-------------------------------------------------------------------------
*/
}
+static void
+check_xact_readonly(Node *parsetree)
+{
+ if (!XactReadOnly)
+ return;
+
+ /*
+ * Note: Commands that need to do more complicated checking are
+ * handled elsewhere.
+ */
+
+ switch (nodeTag(parsetree))
+ {
+ case T_AlterDatabaseSetStmt:
+ case T_AlterDomainStmt:
+ case T_AlterGroupStmt:
+ case T_AlterTableStmt:
+ case T_RenameStmt:
+ case T_AlterUserStmt:
+ case T_AlterUserSetStmt:
+ case T_CommentStmt:
+ case T_DefineStmt:
+ case T_CreateCastStmt:
+ case T_CreateConversionStmt:
+ case T_CreatedbStmt:
+ case T_CreateDomainStmt:
+ case T_CreateFunctionStmt:
+ case T_CreateGroupStmt:
+ case T_IndexStmt:
+ case T_CreatePLangStmt:
+ case T_CreateOpClassStmt:
+ case T_RuleStmt:
+ case T_CreateSchemaStmt:
+ case T_CreateSeqStmt:
+ case T_CreateStmt:
+ case T_CreateTrigStmt:
+ case T_CompositeTypeStmt:
+ case T_CreateUserStmt:
+ case T_ViewStmt:
+ case T_RemoveAggrStmt:
+ case T_DropCastStmt:
+ case T_DropStmt:
+ case T_DropdbStmt:
+ case T_RemoveFuncStmt:
+ case T_DropGroupStmt:
+ case T_DropPLangStmt:
+ case T_RemoveOperStmt:
+ case T_RemoveOpClassStmt:
+ case T_DropPropertyStmt:
+ case T_DropUserStmt:
+ case T_GrantStmt:
+ case T_TruncateStmt:
+ elog(ERROR, "transaction is read-only");
+ break;
+ default:
+ /*nothing*/;
+ }
+}
+
+
/*
* ProcessUtility
* general utility function invoker
CommandDest dest,
char *completionTag)
{
+ check_xact_readonly(parsetree);
+
if (completionTag)
completionTag[0] = '\0';
{
BeginTransactionBlock();
- /*
- * Currently, the only option that can be set
- * by START TRANSACTION is the isolation
- * level.
- */
if (stmt->options)
{
- SetPGVariable("TRANSACTION ISOLATION LEVEL",
- stmt->options,
- false);
+ List *head;
+
+ foreach(head, stmt->options)
+ {
+ DefElem *item = (DefElem *) lfirst(head);
+
+ if (strcmp(item->defname, "transaction_isolation")==0)
+ SetPGVariable("transaction_isolation",
+ makeList1(item->arg), false);
+ else if (strcmp(item->defname, "transaction_read_only")==0)
+ SetPGVariable("transaction_read_only",
+ makeList1(item->arg), false);
+ }
}
}
break;
{
VariableSetStmt *n = (VariableSetStmt *) parsetree;
- SetPGVariable(n->name, n->args, n->is_local);
+ /*
+ * Special cases for special SQL syntax that
+ * effectively sets more than one variable per
+ * statement.
+ */
+ if (strcmp(n->name, "TRANSACTION")==0)
+ {
+ List *head;
+
+ foreach(head, n->args)
+ {
+ DefElem *item = (DefElem *) lfirst(head);
+
+ if (strcmp(item->defname, "transaction_isolation")==0)
+ SetPGVariable("transaction_isolation",
+ makeList1(item->arg), n->is_local);
+ else if (strcmp(item->defname, "transaction_read_only")==0)
+ SetPGVariable("transaction_read_only",
+ makeList1(item->arg), n->is_local);
+ }
+ }
+ else if (strcmp(n->name, "SESSION CHARACTERISTICS")==0)
+ {
+ List *head;
+
+ foreach(head, n->args)
+ {
+ DefElem *item = (DefElem *) lfirst(head);
+
+ if (strcmp(item->defname, "transaction_isolation")==0)
+ SetPGVariable("default_transaction_isolation",
+ makeList1(item->arg), n->is_local);
+ else if (strcmp(item->defname, "transaction_read_only")==0)
+ SetPGVariable("default_transaction_read_only",
+ makeList1(item->arg), n->is_local);
+ }
+ }
+ else
+ SetPGVariable(n->name, n->args, n->is_local);
}
break;
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.109 2002/12/27 14:06:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.110 2003/01/10 22:03:29 petere Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut
.
{"autocommit", PGC_USERSET}, &autocommit,
true, NULL, NULL
},
+ {
+ {"default_transaction_read_only", PGC_USERSET}, &DefaultXactReadOnly,
+ false, NULL, NULL
+ },
+ {
+ {"transaction_read_only", PGC_USERSET, GUC_NO_RESET_ALL}, &XactReadOnly,
+ false, NULL, NULL
+ },
{
{NULL, 0}, NULL, false, NULL, NULL
},
{
- {"TRANSACTION ISOLATION LEVEL", PGC_USERSET, GUC_NO_RESET_ALL},
+ {"transaction_isolation", PGC_USERSET, GUC_NO_RESET_ALL},
&XactIsoLevel_string,
NULL, assign_XactIsoLevel, show_XactIsoLevel
},
guc_string_workspace = NULL;
/*
- * Prevent any attempt to override TRANSACTION ISOLATION LEVEL from
+ * Prevent any attempt to override the transaction modes from
* non-interactive sources.
*/
- SetConfigOption("TRANSACTION ISOLATION LEVEL", "default",
+ SetConfigOption("transaction_isolation", "default",
+ PGC_POSTMASTER, PGC_S_OVERRIDE);
+ SetConfigOption("transaction_read_only", "no",
PGC_POSTMASTER, PGC_S_OVERRIDE);
/*
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.70 2002/12/13 05:36:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.71 2003/01/10 22:03:30 petere Exp $
*/
/*----------------------------------------------------------------------
"CONSTRAINTS",
"NAMES",
"SESSION",
- "TRANSACTION ISOLATION LEVEL",
- /* these are treated in backend/commands/variable.c */
- "DateStyle",
- "TimeZone",
- "client_encoding",
- "server_encoding",
- "seed",
+ "TRANSACTION",
/*
* the rest should match USERSET entries in
"autocommit",
"checkpoint_segments",
"checkpoint_timeout",
+ "client_encoding",
"client_min_messages",
"commit_delay",
"commit_siblings",
"cpu_index_tuple_cost",
"cpu_operator_cost",
"cpu_tuple_cost",
+ "DateStyle",
"db_user_namespace",
"deadlock_timeout",
"debug_pretty_print",
"lc_messages",
"lc_monetary",
"lc_numeric",
- "lc_timeC",
+ "lc_time",
"log_connections",
"log_duration",
"log_min_error_statement",
"log_planner_stats",
"log_source_port",
"log_statement_stats",
+ "seed",
+ "server_encoding",
"silent_mode",
"sort_mem",
"sql_inheritance",
"syslog_facility",
"syslog_ident",
"tcpip_socket",
+ "TimeZone",
"trace_notify",
"transform_null_equals",
"unix_socket_directory",
strcasecmp(prev_wd, "RESET") == 0 ||
strcasecmp(prev_wd, "SHOW") == 0)
COMPLETE_WITH_LIST(pgsql_variables);
- /* Complete "SET TRANSACTION ISOLOLATION LEVEL" */
- else if (strcasecmp(prev2_wd, "SET") == 0 &&
- strcasecmp(prev_wd, "TRANSACTION") == 0)
- COMPLETE_WITH_CONST("ISOLATION");
+ /* Complete "SET TRANSACTION" */
+ else if ((strcasecmp(prev2_wd, "SET") == 0 &&
+ strcasecmp(prev_wd, "TRANSACTION") == 0) ||
+ (strcasecmp(prev4_wd, "SESSION") == 0 &&
+ strcasecmp(prev3_wd, "CHARACTERISTICS") == 0 &&
+ strcasecmp(prev2_wd, "AS") == 0 &&
+ strcasecmp(prev_wd, "TRANSACTION") == 0))
+ {
+ char *my_list[] = {"ISOLATION", "READ", NULL};
+
+ COMPLETE_WITH_LIST(my_list);
+ }
else if (strcasecmp(prev3_wd, "SET") == 0 &&
strcasecmp(prev2_wd, "TRANSACTION") == 0 &&
strcasecmp(prev_wd, "ISOLATION") == 0)
strcasecmp(prev2_wd, "LEVEL") == 0 &&
strcasecmp(prev_wd, "READ") == 0)
COMPLETE_WITH_CONST("COMMITTED");
+ else if ((strcasecmp(prev3_wd, "SET") == 0 ||
+ strcasecmp(prev3_wd, "AS") == 0) &&
+ strcasecmp(prev2_wd, "TRANSACTION") == 0 &&
+ strcasecmp(prev_wd, "READ") == 0)
+ {
+ char *my_list[] = {"ONLY", "WRITE", NULL};
+
+ COMPLETE_WITH_LIST(my_list);
+ }
/* Complete SET CONSTRAINTS with DEFERRED|IMMEDIATE */
else if (strcasecmp(prev3_wd, "SET") == 0 &&
strcasecmp(prev2_wd, "CONSTRAINTS") == 0)
strcasecmp(prev_wd, "SESSION") == 0)
{
char *my_list[] = {"AUTHORIZATION",
- "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL",
+ "CHARACTERISTICS AS TRANSACTION",
NULL};
COMPLETE_WITH_LIST(my_list);
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xact.h,v 1.48 2002/11/18 01:17:39 tgl Exp $
+ * $Id: xact.h,v 1.49 2003/01/10 22:03:30 petere Exp $
*
*-------------------------------------------------------------------------
*/
extern int DefaultXactIsoLevel;
extern int XactIsoLevel;
+extern bool DefaultXactReadOnly;
+extern bool XactReadOnly;
+
/* ----------------
* transaction state structure
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: namespace.h,v 1.24 2003/01/07 20:56:07 tgl Exp $
+ * $Id: namespace.h,v 1.25 2003/01/10 22:03:30 petere Exp $
*
*-------------------------------------------------------------------------
*/
extern Oid RangeVarGetRelid(const RangeVar *relation, bool failOK);
extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
extern Oid RelnameGetRelid(const char *relname);
+extern Oid RelidGetNamespaceId(Oid relid);
extern bool RelationIsVisible(Oid relid);
extern Oid TypenameGetTypid(const char *typname);
42 | 324.78
(4 rows)
+-- Read-only tests
+CREATE TABLE writetest (a int);
+CREATE TEMPORARY TABLE temptest (a int);
+SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
+DROP TABLE writetest; -- fail
+ERROR: transaction is read-only
+INSERT INTO writetest VALUES (1); -- fail
+ERROR: transaction is read-only
+SELECT * FROM writetest; -- ok
+ a
+---
+(0 rows)
+
+DELETE FROM temptest; -- ok
+UPDATE temptest SET a = 0 WHERE a = 1 AND writetest.a = temptest.a; -- ok
+PREPARE test AS UPDATE writetest SET a = 0; -- ok
+EXECUTE test; -- fail
+ERROR: transaction is read-only
+SELECT * FROM writetest, temptest; -- ok
+ a | a
+---+---
+(0 rows)
+
+CREATE TABLE test AS SELECT * FROM writetest; -- fail
+ERROR: transaction is read-only
+START TRANSACTION READ WRITE;
+DROP TABLE writetest; -- ok
+COMMIT;
-- should have members again
SELECT * FROM aggtest;
+
+-- Read-only tests
+
+CREATE TABLE writetest (a int);
+CREATE TEMPORARY TABLE temptest (a int);
+
+SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
+
+DROP TABLE writetest; -- fail
+INSERT INTO writetest VALUES (1); -- fail
+SELECT * FROM writetest; -- ok
+DELETE FROM temptest; -- ok
+UPDATE temptest SET a = 0 WHERE a = 1 AND writetest.a = temptest.a; -- ok
+PREPARE test AS UPDATE writetest SET a = 0; -- ok
+EXECUTE test; -- fail
+SELECT * FROM writetest, temptest; -- ok
+CREATE TABLE test AS SELECT * FROM writetest; -- fail
+
+START TRANSACTION READ WRITE;
+DROP TABLE writetest; -- ok
+COMMIT;