File: positionedDelUpd.out

package info (click to toggle)
derby 10.14.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 79,056 kB
  • sloc: java: 691,961; sql: 42,686; xml: 20,512; sh: 3,373; sed: 96; makefile: 60
file content (1191 lines) | stat: -rw-r--r-- 56,382 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
ij> --
--   Licensed to the Apache Software Foundation (ASF) under one or more
--   contributor license agreements.  See the NOTICE file distributed with
--   this work for additional information regarding copyright ownership.
--   The ASF licenses this file to You under the Apache License, Version 2.0
--   (the "License"); you may not use this file except in compliance with
--   the License.  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--   Unless required by applicable law or agreed to in writing, software
--   distributed under the License is distributed on an "AS IS" BASIS,
--   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--   See the License for the specific language governing permissions and
--   limitations under the License.
--
-- ** insert positionedDelete.sql
--
-- tests for positioned delete
--
-- note that comments that begin '-- .' are test cases from the test plan

-- assumed available in queries at time of initial writing:
-- subqueries.  Additional tests will be needed once we have:
-- order by, group by, having, aggregates, distinct, views ...

-- setup some tables for use in the tests

create table t1 ( i int, v varchar(10), d double precision, t time );
0 rows inserted/updated/deleted
ij> create table t1_copy ( i int, v varchar(10), d double precision, t time );
0 rows inserted/updated/deleted
ij> create table t2 ( s smallint, c char(10), r real, ts timestamp );
0 rows inserted/updated/deleted
ij> -- populate the first table and copy
insert into t1 values (1, '1111111111', 11e11, time('11:11:11'));
1 row inserted/updated/deleted
ij> insert into t1_copy select * from t1;
1 row inserted/updated/deleted
ij> -- we need to turn autocommit off so that cursors aren't closed before
-- the positioned statements against them.
autocommit off;
ij> -- empty table tests

-- .no table name given
-- this should fail with a syntax error
delete;
ERROR 42X01: Syntax error: Encountered "<EOF>" at line 5, column 6.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this should succeed
get cursor c0 as 'select * from t1 for update';
ij> next c0;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c0;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c0;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .same table name
-- .cursor before 1st row
get cursor c1 as 'select * from t2 for update';
ij> -- 'cursor not on a row' expected
delete from t2 where current of c1;
ERROR 24000: Invalid cursor state - no current row.
ij> -- .different table name
delete from t1 where current of c1;
ERROR 42X28: Delete table 'T1' is not target of cursor 'C1'.
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .non-existant table
delete from not_exists where current of c1;
ERROR 42X28: Delete table 'NOT_EXISTS' is not target of cursor 'C1'.
ij> close c1;
ij> -- .delete from  base table, not exposed table name
-- (this one should work, since base table)
get cursor c2 as 'select * from t2 asdf for update';
ij> delete from t2 where current of c2;
ERROR 24000: Invalid cursor state - no current row.
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .match correlation name
-- (this one should fail, since correlation name)
delete from asdf where current of c2;
ERROR 42X28: Delete table 'ASDF' is not target of cursor 'C2'.
ij> close c2;
ij> -- .non-updatable cursor
-- NOTE - forupdate responsible for extensive tests
get cursor c3 as 'select * from t2 for read only';
ij> delete from t2 where current of c3;
ERROR 42X23: Cursor C3 is not updatable.
ij> close c3;
ij> -- .target cursor does not exist
delete from t2 where current of c44;
ERROR 42X30: Cursor 'C44' not found. Verify that autocommit is off.
ij> -- .target cursor after last row
get cursor c4 as 'select * from t1 for update';
ij> next c4;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> next c4;
No current row
ij> next c4;
No current row
ij> delete from t1 where current of c4;
ERROR 24000: Invalid cursor state - no current row.
ij> close c4;
ij> -- .target cursor exists, closed
get cursor c5 as 'select * from t1';
ij> close c5;
ij> delete from t1 where current of c5;
ERROR 42X30: Cursor 'C5' not found. Verify that autocommit is off.
ij> -- .target cursor on row
get cursor c6 as 'select * from t1 for update';
ij> next c6;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c6;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c6;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .target cursor on row deleted by another cursor
get cursor c7 as 'select * from t1 for update';
ij> next c7;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> get cursor c8 as 'select * from t1 for update';
ij> next c8;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c7;
1 row inserted/updated/deleted
ij> delete from t1 where current of c8;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c7;
ij> close c8;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .target cursor on already deleted row
get cursor c9 as 'select * from t1 for update';
ij> next c9;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c9;
1 row inserted/updated/deleted
ij> delete from t1 where current of c9;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c9;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- delete to row which was subject to searched update
-- (row still within cursor qualification)
get cursor c10 as 'select * from t1 for update';
ij> next c10;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c10;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c10;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- delete to row which was subject to searched update
-- (row becomes outside of cursor qualification)
get cursor c10a as 'select * from t1 where i = 1 for update';
ij> next c10a;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c10a;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> close c10a;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- delete to row which was subject to positioned update
-- (row becomes outside of cursor qualification)
get cursor c11 as 'select * from t1 where i = 1 for update';
ij> next c11;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1 where current of c11;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c11;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> close c11;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- delete to row which was subject to 2 searched updates
-- (1st puts row outside of cursor qualification, 2nd restores it)
get cursor c12 as 'select * from t1 where i = 1 for update';
ij> next c12;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> update t1 set i = 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c12;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c12;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- positioned delete on table with index (#724)
create table t5 (c1 int, c2 int);
0 rows inserted/updated/deleted
ij> insert into t5 values (1, 1), (2, 2), (3, 3), (4, 4);
4 rows inserted/updated/deleted
ij> commit;
ij> create index i5 on t5(c1);
0 rows inserted/updated/deleted
ij> get cursor c1 as 'select * from t5 where c1 > 1 for update of c2';
ij> next c1;
C1         |C2         
-----------------------
2          |2          
ij> delete from t5 where current of c1;
1 row inserted/updated/deleted
ij> next c1;
C1         |C2         
-----------------------
3          |3          
ij> next c1;
C1         |C2         
-----------------------
4          |4          
ij> delete from t5 where current of c1;
1 row inserted/updated/deleted
ij> select * from t5;
C1         |C2         
-----------------------
1          |1          
3          |3          
ij> close c1;
ij> rollback;
ij> create index i5 on t5(c2);
0 rows inserted/updated/deleted
ij> get cursor c1 as 'select * from t5 where c1 > 1 for update of c2';
ij> next c1;
C1         |C2         
-----------------------
2          |2          
ij> delete from t5 where current of c1;
1 row inserted/updated/deleted
ij> next c1;
C1         |C2         
-----------------------
3          |3          
ij> next c1;
C1         |C2         
-----------------------
4          |4          
ij> delete from t5 where current of c1;
1 row inserted/updated/deleted
ij> select * from t5;
C1         |C2         
-----------------------
1          |1          
3          |3          
ij> close c1;
ij> rollback;
ij> -- reset autocommit
autocommit on;
ij> -- drop the tables
drop table t1;
0 rows inserted/updated/deleted
ij> drop table t2;
0 rows inserted/updated/deleted
ij> drop table t5;
0 rows inserted/updated/deleted
ij> drop table t1_copy;
0 rows inserted/updated/deleted
ij> -- ** insert positionedUpdate.sql
--
-- tests for positioned update
--
-- note that comments that begin '-- .' are test cases from the test plan

-- assumed available in queries at time of initial writing:
-- subqueries.  Additional tests will be needed once we have:
-- order by, group by, having, aggregates, distinct, views ...

-- setup some tables for use in the tests

create table t1 ( i int, v varchar(10), d double precision, t time );
0 rows inserted/updated/deleted
ij> create table t1_copy ( i int, v varchar(10), d double precision, t time );
0 rows inserted/updated/deleted
ij> create table t2 ( s smallint, c char(10), r real, ts timestamp );
0 rows inserted/updated/deleted
ij> -- populate the first table and copy
insert into t1 values (1, '1111111111', 11e11, time('11:11:11'));
1 row inserted/updated/deleted
ij> insert into t1_copy select * from t1;
1 row inserted/updated/deleted
ij> -- we need to turn autocommit off so that cursors aren't closed before
-- the positioned statements against them.
autocommit off;
ij> -- empty table tests

-- .no table name given
-- this should fail with a syntax error
update set c1 = c1;
ERROR 42X01: Syntax error: Encountered "set" at line 5, column 8.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this should succeed
get cursor c0 as 'select * from t1 for update';
ij> next c0;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = 999 where current of c0;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
999        |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = 1 where current of c0;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> close c0;
ij> -- .same table name
-- .cursor before 1st row
get cursor c1 as 'select * from t2 for update';
ij> -- 'cursor not on a row' expected
update t2 set s = s where current of c1;
ERROR 24000: Invalid cursor state - no current row.
ij> -- .different table name
update t1 set i = i where current of c1;
ERROR 42X29: Update table 'T1' is not the target of cursor 'C1'.
ij> -- .non-existant table
update not_exists set i = i where current of c1;
ERROR 42X29: Update table 'NOT_EXISTS' is not the target of cursor 'C1'.
ij> close c1;
ij> -- .update base table, not exposed table name
-- (this one should work, since base table)
get cursor c2 as 'select * from t2 asdf for update';
ij> update t2 set s = s where current of c2;
ERROR 24000: Invalid cursor state - no current row.
ij> -- .match correlation name
-- (this one should fail, since correlation name)
update asdf set s = s where current of c2;
ERROR 42X29: Update table 'ASDF' is not the target of cursor 'C2'.
ij> close c2;
ij> -- .non-updatable cursor
-- NOTE - forupdate responsible for extensive tests
get cursor c3 as 'select * from t2 for read only';
ij> update t2 set s = s where current of c3;
ERROR 42X23: Cursor C3 is not updatable.
ij> close c3;
ij> -- .target cursor does not exist
update t2 set s = s where current of c44;
ERROR 42X30: Cursor 'C44' not found. Verify that autocommit is off.
ij> -- .target cursor after last row
get cursor c4 as 'select * from t1 for update';
ij> next c4;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> next c4;
No current row
ij> next c4;
No current row
ij> update t1 set i = i where current of c4;
ERROR 24000: Invalid cursor state - no current row.
ij> close c4;
ij> -- .target cursor exists, closed
get cursor c5 as 'select * from t1';
ij> close c5;
ij> update t1 set i = i where current of c5;
ERROR 42X30: Cursor 'C5' not found. Verify that autocommit is off.
ij> -- .target cursor on row
get cursor c6 as 'select * from t1 for update';
ij> next c6;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1 where current of c6;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> -- .consecutive updates to same row in cursor, keeping it in the cursor qual
update t1 set i = i + 1 where current of c6;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
3          |1111111111|1.1E12                  |11:11:11
ij> close c6;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .target cursor on row deleted by another cursor
get cursor c7 as 'select * from t1 for update';
ij> next c7;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> get cursor c8 as 'select * from t1 for update';
ij> next c8;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c7;
1 row inserted/updated/deleted
ij> update t1 set i = i + 1 where current of c8;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c7;
ij> close c8;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .target cursor on already deleted row
get cursor c9 as 'select * from t1 for update';
ij> next c9;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> delete from t1 where current of c9;
1 row inserted/updated/deleted
ij> update t1 set i = i + 1 where current of c9;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
ij> close c9;
ij> -- restore t1
delete from t1;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update to row which was subject to searched update
-- (row still within cursor qualification)
get cursor c10 as 'select * from t1 for update';
ij> next c10;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 2 where current of c10;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
4          |1111111111|1.1E12                  |11:11:11
ij> close c10;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update to row which was subject to searched update
-- (row becomes outside of cursor qualification)
get cursor c10a as 'select * from t1 where i = 1 for update';
ij> next c10a;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 2 where current of c10a;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> close c10a;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update to row which was subject to positioned update
-- (row becomes outside of cursor qualification)
get cursor c11 as 'select * from t1 where i = 1 for update';
ij> next c11;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1 where current of c11;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 2 where current of c11;
ERROR 24000: Invalid cursor state - no current row.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
2          |1111111111|1.1E12                  |11:11:11
ij> close c11;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update to row which was subject to 2 searched updates
-- (1st puts row outside of cursor qualification, 2nd restores it)
get cursor c12 as 'select * from t1 where i = 1 for update';
ij> next c12;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 1;
1 row inserted/updated/deleted
ij> update t1 set i = 1;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> update t1 set i = i + 2 where current of c12;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
3          |1111111111|1.1E12                  |11:11:11
ij> -- negative test - try to update a non-existant column
update t1 set notacolumn = i + 1 where current of c12;
ERROR 42X14: 'NOTACOLUMN' is not a column in table or VTI 'APP.T1'.
ij> close c12;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update column not in SELECT list, but in FOR UPDATE OF list
get cursor c13 as 'select i from t1 for update of v';
ij> next c13;
I          
-----------
1          
ij> update t1 set v = '999' where current of c13;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |999       |1.1E12                  |11:11:11
ij> -- update column not in FOR UPDATE OF list (negative test)
update t1 set i = 999 where current of c13;
ERROR 42X31: Column 'I' is not in the FOR UPDATE list of cursor 'C13'.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |999       |1.1E12                  |11:11:11
ij> close c13;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- update a non-referenced column
get cursor c14 as 'select i from t1 for update';
ij> next c14;
I          
-----------
1          
ij> update t1 set v = '999' where current of c14;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |999       |1.1E12                  |11:11:11
ij> close c14;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .update columns in list in order different from the list's
get cursor c15 as 'select i, v from t1 for update of i, v';
ij> next c15;
I          |V         
----------------------
1          |1111111111
ij> update t1 set v = '999', i = 888 where current of c15;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
888        |999       |1.1E12                  |11:11:11
ij> -- . show that target table name must be used as qualifier, other names not allowed
update t1 set t1.v = '998' where current of c15;
1 row inserted/updated/deleted
ij> update t1 set t2.v = '997' where current of c15;
ERROR 42X55: Table name 'T2' should be the same as 'T1'.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
888        |998       |1.1E12                  |11:11:11
ij> close c15;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .update only 1 column in the list
get cursor c16 as 'select i, v from t1 for update of i, v';
ij> next c16;
I          |V         
----------------------
1          |1111111111
ij> update t1 set v = '999' where current of c16;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |999       |1.1E12                  |11:11:11
ij> close c16;
ij> -- restore t1
delete from t1;
1 row inserted/updated/deleted
ij> insert into t1 select * from t1_copy;
1 row inserted/updated/deleted
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- .try to update through a closed cursor
get cursor c17 as 'select i, v from t1 for update of i, v';
ij> next c17;
I          |V         
----------------------
1          |1111111111
ij> close c17;
ij> update t1 set v = '999' where current of c17;
ERROR 42X30: Cursor 'C17' not found. Verify that autocommit is off.
ij> select * from t1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> -- a positioned update requires a named target table.
-- if we prepare the positioned update, close the underlying cursor
-- and reopen it on a different table, then the positioned update
-- should fail 

create table t3(c1 int, c2 int);
0 rows inserted/updated/deleted
ij> insert into t3 values (1,1), (2, 1), (3,3);
3 rows inserted/updated/deleted
ij> create table t4(c1 int, c2 int);
0 rows inserted/updated/deleted
ij> insert into t4 select * from t3;
3 rows inserted/updated/deleted
ij> get cursor c1 as 'select c1 from t3 for update of c1';
ij> next c1;
C1         
-----------
1          
ij> prepare u1 as 'update t3 set c1 = c1 + 1 where current of c1';
ij> execute u1;
1 row inserted/updated/deleted
ij> next c1;
C1         
-----------
2          
ij> select * from t3;
C1         |C2         
-----------------------
2          |1          
2          |1          
3          |3          
ij> close c1;
ij> get cursor c1 as 'select c1 from t4 for update of c1';
ij> next c1;
C1         
-----------
1          
ij> execute u1;
ERROR 42X29: Update table 'T3' is not the target of cursor 'C1'.
ij> select * from t4;
C1         |C2         
-----------------------
1          |1          
2          |1          
3          |3          
ij> select * from t3;
C1         |C2         
-----------------------
2          |1          
2          |1          
3          |3          
ij> close c1;
ij> -- now, reopen c1 on a table without column c1 and see
-- what happens on an attempted positioned update
get cursor c1 as 'select * from t1 for update';
ij> next c1;
I          |V         |D                       |T       
--------------------------------------------------------
1          |1111111111|1.1E12                  |11:11:11
ij> execute u1;
ERROR 42X29: Update table 'T3' is not the target of cursor 'C1'.
ij> close c1;
ij> -- now, reopen c1 on t3, but as a read only cursor
select * from t3;
C1         |C2         
-----------------------
2          |1          
2          |1          
3          |3          
ij> get cursor c1 as 'select c1 from t3 ';
ij> next c1;
C1         
-----------
2          
ij> execute u1;
ERROR 42X23: Cursor C1 is not updatable.
ij> select * from t3;
C1         |C2         
-----------------------
2          |1          
2          |1          
3          |3          
ij> close c1;
ij> -- positioned update on table with index (#724)
create table t5 (c1 int, c2 int);
0 rows inserted/updated/deleted
ij> insert into t5 values (1, 1), (2, 2), (3, 3), (4, 4);
4 rows inserted/updated/deleted
ij> commit;
ij> create index i5 on t5(c1);
0 rows inserted/updated/deleted
ij> get cursor c1 as 'select * from t5 where c1 > 1 for update of c2';
ij> next c1;
C1         |C2         
-----------------------
2          |2          
ij> update t5 set c2 = 9 where current of c1;
1 row inserted/updated/deleted
ij> next c1;
C1         |C2         
-----------------------
3          |3          
ij> next c1;
C1         |C2         
-----------------------
4          |4          
ij> update t5 set c2 = 9 where current of c1;
1 row inserted/updated/deleted
ij> select * from t5;
C1         |C2         
-----------------------
1          |1          
2          |9          
3          |3          
4          |9          
ij> close c1;
ij> rollback;
ij> create index i5 on t5(c2);
0 rows inserted/updated/deleted
ij> get cursor c1 as 'select * from t5 where c1 > 1 for update of c2';
ij> next c1;
C1         |C2         
-----------------------
2          |2          
ij> update t5 set c2 = 9 where current of c1;
1 row inserted/updated/deleted
ij> next c1;
C1         |C2         
-----------------------
3          |3          
ij> next c1;
C1         |C2         
-----------------------
4          |4          
ij> update t5 set c2 = 9 where current of c1;
1 row inserted/updated/deleted
ij> select * from t5;
C1         |C2         
-----------------------
1          |1          
2          |9          
3          |3          
4          |9          
ij> close c1;
ij> rollback;
ij> -- reset autocommit
autocommit on;
ij> -- drop the tables
drop table t1;
0 rows inserted/updated/deleted
ij> drop table t2;
0 rows inserted/updated/deleted
ij> drop table t3;
0 rows inserted/updated/deleted
ij> drop table t4;
0 rows inserted/updated/deleted
ij> drop table t5;
0 rows inserted/updated/deleted
ij> drop table t1_copy;
0 rows inserted/updated/deleted
ij> -- tests for beetle 4417, schema and correlation name not working with
-- current of
create schema ejb;
0 rows inserted/updated/deleted
ij> create table ejb.test1
	(primarykey varchar(41) not null primary key,
	name varchar(200),
	parentkey varchar(41));
0 rows inserted/updated/deleted
ij> insert into ejb.test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> autocommit off;
ij> -- test update with schema name
get cursor c1 as 'select primarykey, parentkey, name from ejb.test1 where primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p1 as 'update ejb.test1 set name = ''john'' where current of c1';
ij> execute p1;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |john                                                                                                                            
ij> close c1;
ij> -- test update with schema name and correlation name
get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from ejb.test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |john                                                                                                                            
ij> prepare p1 as 'update ejb.test1 set name = ''joe'' where current of c1';
ij> execute p1;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> close c1;
ij> -- test update with set schema
set schema ejb;
0 rows inserted/updated/deleted
ij> get cursor c1 as 'select primarykey, parentkey, name from test1 where primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> prepare p1 as 'update test1 set name = ''john'' where current of c1';
ij> execute p1;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |john                                                                                                                            
ij> close c1;
ij> -- test update with set schema and correlation name
get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |john                                                                                                                            
ij> prepare p1 as 'update test1 set name = ''joe'' where current of c1';
ij> execute p1;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> close c1;
ij> -- test update with set schema and correlation name and schema name
get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from ejb.test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> prepare p1 as 'update ejb.test1 set name = ''joe'' where current of c1';
ij> execute p1;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> close c1;
ij> -- 
-- reset schema name
set schema app;
0 rows inserted/updated/deleted
ij> -- test delete with schema name 
get cursor c1 as 'select primarykey, parentkey, name from ejb.test1 where primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |joe                                                                                                                             
ij> prepare p2 as 'delete from ejb.test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> -- test delete with schema name and correlation name
insert into ejb.test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from ejb.test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p2 as 'delete from ejb.test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> -- test delete with set schema 
set schema ejb;
0 rows inserted/updated/deleted
ij> insert into test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> get cursor c1 as 'select primarykey, parentkey, name from test1 where primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p2 as 'delete from test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> -- test delete with set schema and correlation name
insert into test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p2 as 'delete from test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> -- test delete with set schema and correlation name and schema name
insert into test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from ejb.test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p2 as 'delete from ejb.test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from ejb.test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> commit;
ij> -- clean up
autocommit on;
ij> set schema app;
0 rows inserted/updated/deleted
ij> drop table ejb.test1;
0 rows inserted/updated/deleted
ij> --drop schema ejb restrict; - can't drop this because it will fail SPS tests since
--statements are created and would need to be dropped

-- test correlation on select in current of cursor in current schema
-- this was also broken
create table test1
	(primarykey varchar(41) not null primary key,
	name varchar(200),
	parentkey varchar(41));
0 rows inserted/updated/deleted
ij> -- make sure a cursor will work fine in this situation
insert into test1 values('0','jack','jill');
1 row inserted/updated/deleted
ij> autocommit off;
ij> get cursor c1 as 'select t1.primarykey, t1.parentkey, t1.name from test1 t1 where t1.primarykey = ''0'' for update';
ij> next c1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0                                        |jill                                     |jack                                                                                                                            
ij> prepare p2 as 'delete from test1 where current of c1';
ij> execute p2;
1 row inserted/updated/deleted
ij> select primarykey, parentkey, name from test1;
PRIMARYKEY                               |PARENTKEY                                |NAME                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ij> close c1;
ij> commit;
ij> -- clean up
autocommit on;
ij> drop table test1;
0 rows inserted/updated/deleted
ij>