Bug 6981 - Oct2020: PREPARE DDL statement silently fails
Summary: Oct2020: PREPARE DDL statement silently fails
Status: RESOLVED FIXED
Alias: None
Product: SQL
Classification: Unclassified
Component: all (show other bugs)
Version: -- development
Hardware: Other Linux
: Normal normal
Assignee: SQL devs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-02 11:37 CEST by Roberto Cornacchia
Modified: 2020-11-24 11:37 CET (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Cornacchia 2020-10-02 11:37:17 CEST
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
Build Identifier: 

Before Oct2020 it was possible to prepare and execute a DDL statement:

sql>PREPARE create table t as select 3;
execute prepared statement using: EXEC 5(...)
+------+--------+-------+--------+-------+--------+
| type | digits | scale | schema | table | column |
+======+========+=======+========+=======+========+
+------+--------+-------+--------+-------+--------+
0 tuples
sql>EXEC 5();
operation successful


In Oct2020, this results in:

sql>PREPARE create table t as select 3;
execute prepared statement using: EXEC 0(...)
+------+--------+-------+--------+-------+--------+
| type | digits | scale | schema | table | column |
+======+========+=======+========+=======+========+
+------+--------+-------+--------+-------+--------+
0 tuples
sql>EXEC 0();
EXEC: PREPARED Statement missing '0'

The bug is either:
- prepare DDL no longer works correctly
- prepare DDL is no longer allowed, but no error is reported upon prepare


I hope it's the first. 

Reproducible: Always
Comment 1 Pedro Ferreira 2020-10-02 12:46:37 CEST
Hello Roberto,

DDL inside prepared statements is something that we never took care actually, because it's something difficult to manage altogether. Currently, whenever a schema change is made, the query cache is cleaned (e.g. drop column statement). There were changes on the query cache on Oct2020 which caused this issue, but it won't be worth to fix for now.

However I'm planning soon to work on a feature branch where prepared statements will be recompiled whenever a schema change is made.
Comment 2 Niels Nes cwiconfidential 2020-11-03 08:59:20 CET
found a small improvement on this, ie don't clean the cache on prepare statements.
Comment 3 MonetDB Mercurial Repository cwiconfidential 2020-11-03 09:00:31 CET
Changeset dc247c82fba7, made by Niels Nes <niels@cwi.nl> in the MonetDB repo, refers to this bug.

For complete details, see https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dc247c82fba7

Changeset description:

	fix bug 6981, ie don't clean the query cache on prepare statements