Skip to content

Commit ceee5bc

Browse files
author
Jesse Seldess
authored
Merge pull request #1859 from cockroachdb/known-limitation
Add known limitation around dropping interleaved indexes
2 parents be63167 + f3f1313 commit ceee5bc

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

v1.0/known-limitations.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,63 @@ Also, a prepared [`INSERT`](insert.html), [`UPSERT`](upsert.html), or [`DELETE`]
280280

281281
- If the number of columns has increased, the prepared statement returns an error but nonetheless writes the data.
282282
- If the number of columns remains the same but the types have changed, the prepared statement writes the data and does not return an error.
283+
284+
## Dropping an index interleaved into another index on the same table
285+
286+
In the unlikely case that you [interleave](interleave-in-parent.html) an index into another index on the same table and then [drop](drop-index.html) the interleaved index, future DDL operations on the table will fail.
287+
288+
For example:
289+
290+
~~~ sql
291+
> CREATE TABLE t1 (id1 INT PRIMARY KEY, id2 INT, id3 INT);
292+
~~~
293+
294+
~~~ sql
295+
> CREATE INDEX c ON t1 (id2)
296+
STORING (id1, id3)
297+
INTERLEAVE IN PARENT t1 (id2);
298+
~~~
299+
300+
~~~ sql
301+
> SHOW INDEXES FROM t1;
302+
~~~
303+
304+
~~~
305+
+-------+---------+--------+-----+--------+-----------+---------+----------+
306+
| Table | Name | Unique | Seq | Column | Direction | Storing | Implicit |
307+
+-------+---------+--------+-----+--------+-----------+---------+----------+
308+
| t1 | primary | true | 1 | id1 | ASC | false | false |
309+
| t1 | c | false | 1 | id2 | ASC | false | false |
310+
| t1 | c | false | 2 | id1 | N/A | true | false |
311+
| t1 | c | false | 3 | id3 | N/A | true | false |
312+
+-------+---------+--------+-----+--------+-----------+---------+----------+
313+
(4 rows)
314+
~~~
315+
316+
~~~ sql
317+
> DROP INDEX t1@c;
318+
~~~
319+
320+
~~~ sql
321+
> DROP TABLE t1;
322+
~~~
323+
324+
~~~
325+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
326+
~~~
327+
328+
~~~ sql
329+
> TRUNCATE TABLE t1;
330+
~~~
331+
332+
~~~
333+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
334+
~~~
335+
336+
~~~ sql
337+
> ALTER TABLE t1 RENAME COLUMN id3 TO id4;
338+
~~~
339+
340+
~~~
341+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
342+
~~~

v1.1/known-limitations.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,63 @@ Also, a prepared [`INSERT`](insert.html), [`UPSERT`](upsert.html), or [`DELETE`]
201201

202202
- If the number of columns has increased, the prepared statement returns an error but nonetheless writes the data.
203203
- If the number of columns remains the same but the types have changed, the prepared statement writes the data and does not return an error.
204+
205+
## Dropping an index interleaved into another index on the same table
206+
207+
In the unlikely case that you [interleave](interleave-in-parent.html) an index into another index on the same table and then [drop](drop-index.html) the interleaved index, future DDL operations on the table will fail.
208+
209+
For example:
210+
211+
~~~ sql
212+
> CREATE TABLE t1 (id1 INT PRIMARY KEY, id2 INT, id3 INT);
213+
~~~
214+
215+
~~~ sql
216+
> CREATE INDEX c ON t1 (id2)
217+
STORING (id1, id3)
218+
INTERLEAVE IN PARENT t1 (id2);
219+
~~~
220+
221+
~~~ sql
222+
> SHOW INDEXES FROM t1;
223+
~~~
224+
225+
~~~
226+
+-------+---------+--------+-----+--------+-----------+---------+----------+
227+
| Table | Name | Unique | Seq | Column | Direction | Storing | Implicit |
228+
+-------+---------+--------+-----+--------+-----------+---------+----------+
229+
| t1 | primary | true | 1 | id1 | ASC | false | false |
230+
| t1 | c | false | 1 | id2 | ASC | false | false |
231+
| t1 | c | false | 2 | id1 | N/A | true | false |
232+
| t1 | c | false | 3 | id3 | N/A | true | false |
233+
+-------+---------+--------+-----+--------+-----------+---------+----------+
234+
(4 rows)
235+
~~~
236+
237+
~~~ sql
238+
> DROP INDEX t1@c;
239+
~~~
240+
241+
~~~ sql
242+
> DROP TABLE t1;
243+
~~~
244+
245+
~~~
246+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
247+
~~~
248+
249+
~~~ sql
250+
> TRUNCATE TABLE t1;
251+
~~~
252+
253+
~~~
254+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
255+
~~~
256+
257+
~~~ sql
258+
> ALTER TABLE t1 RENAME COLUMN id3 TO id4;
259+
~~~
260+
261+
~~~
262+
pq: invalid interleave backreference table=t1 index=3: index-id "3" does not exist
263+
~~~

0 commit comments

Comments
 (0)