|
| 1 | +CREATE EXTENSION multicorn; |
| 2 | +CREATE server multicorn_srv foreign data wrapper multicorn options ( |
| 3 | + wrapper 'multicorn.testfdw.TestForeignDataWrapper' |
| 4 | +); |
| 5 | +CREATE user mapping FOR current_user server multicorn_srv options (usermapping 'test'); |
| 6 | +CREATE foreign table testmulticorn ( |
| 7 | + test1 character varying, |
| 8 | + test2 character varying |
| 9 | +) server multicorn_srv options ( |
| 10 | + option1 'option1', |
| 11 | + test_type 'nowrite', |
| 12 | + tx_hook 'true' |
| 13 | +); |
| 14 | +insert into testmulticorn(test1, test2) VALUES ('test', 'test2'); |
| 15 | +NOTICE: [('option1', 'option1'), ('test_type', 'nowrite'), ('tx_hook', 'true'), ('usermapping', 'test')] |
| 16 | +NOTICE: [('test1', 'character varying'), ('test2', 'character varying')] |
| 17 | +NOTICE: BEGIN |
| 18 | +NOTICE: ROLLBACK |
| 19 | +ERROR: Error in python: NotImplementedError |
| 20 | +DETAIL: This FDW does not support the writable API |
| 21 | +update testmulticorn set test1 = 'test'; |
| 22 | +NOTICE: BEGIN |
| 23 | +NOTICE: [] |
| 24 | +NOTICE: ['test1', 'test2'] |
| 25 | +ERROR: Error in python: NotImplementedError |
| 26 | +DETAIL: This FDW does not support the writable API |
| 27 | +NOTICE: ROLLBACK |
| 28 | +delete from testmulticorn where test2 = 'test2 2 0'; |
| 29 | +NOTICE: BEGIN |
| 30 | +NOTICE: [test2 = test2 2 0] |
| 31 | +NOTICE: ['test1', 'test2'] |
| 32 | +NOTICE: ROLLBACK |
| 33 | +ERROR: Error in python: NotImplementedError |
| 34 | +DETAIL: This FDW does not support the writable API |
| 35 | +CREATE foreign table testmulticorn_write ( |
| 36 | + test1 character varying, |
| 37 | + test2 character varying |
| 38 | +) server multicorn_srv options ( |
| 39 | + option1 'option1', |
| 40 | + row_id_column 'test1', |
| 41 | + test_type 'returning', |
| 42 | + tx_hook 'true' |
| 43 | +); |
| 44 | +insert into testmulticorn_write(test1, test2) VALUES ('test', 'test2'); |
| 45 | +NOTICE: [('option1', 'option1'), ('row_id_column', 'test1'), ('test_type', 'returning'), ('tx_hook', 'true'), ('usermapping', 'test')] |
| 46 | +NOTICE: [('test1', 'character varying'), ('test2', 'character varying')] |
| 47 | +NOTICE: BEGIN |
| 48 | +NOTICE: INSERTING: [('test1', 'test'), ('test2', 'test2')] |
| 49 | +NOTICE: PRECOMMIT |
| 50 | +NOTICE: COMMIT |
| 51 | +update testmulticorn_write set test1 = 'test' where test1 ilike 'test1 3%'; |
| 52 | +NOTICE: BEGIN |
| 53 | +NOTICE: [test1 ~~* test1 3%] |
| 54 | +NOTICE: ['test1', 'test2'] |
| 55 | +NOTICE: UPDATING: test1 3 1 with [('test1', 'test'), ('test2', 'test2 1 1')] |
| 56 | +NOTICE: UPDATING: test1 3 4 with [('test1', 'test'), ('test2', 'test2 1 4')] |
| 57 | +NOTICE: UPDATING: test1 3 7 with [('test1', 'test'), ('test2', 'test2 1 7')] |
| 58 | +NOTICE: UPDATING: test1 3 10 with [('test1', 'test'), ('test2', 'test2 1 10')] |
| 59 | +NOTICE: UPDATING: test1 3 13 with [('test1', 'test'), ('test2', 'test2 1 13')] |
| 60 | +NOTICE: UPDATING: test1 3 16 with [('test1', 'test'), ('test2', 'test2 1 16')] |
| 61 | +NOTICE: UPDATING: test1 3 19 with [('test1', 'test'), ('test2', 'test2 1 19')] |
| 62 | +NOTICE: PRECOMMIT |
| 63 | +NOTICE: COMMIT |
| 64 | +delete from testmulticorn_write where test2 = 'test2 2 0'; |
| 65 | +NOTICE: BEGIN |
| 66 | +NOTICE: [test2 = test2 2 0] |
| 67 | +NOTICE: ['test1', 'test2'] |
| 68 | +NOTICE: DELETING: test1 1 0 |
| 69 | +NOTICE: PRECOMMIT |
| 70 | +NOTICE: COMMIT |
| 71 | +-- Test returning |
| 72 | +insert into testmulticorn_write(test1, test2) VALUES ('test', 'test2') RETURNING test1; |
| 73 | +NOTICE: BEGIN |
| 74 | +NOTICE: INSERTING: [('test1', 'test'), ('test2', 'test2')] |
| 75 | +NOTICE: PRECOMMIT |
| 76 | +NOTICE: COMMIT |
| 77 | + test1 |
| 78 | +---------------- |
| 79 | + INSERTED: test |
| 80 | +(1 row) |
| 81 | + |
| 82 | +update testmulticorn_write set test1 = 'test' where test1 ilike 'test1 3%' RETURNING test1; |
| 83 | +NOTICE: BEGIN |
| 84 | +NOTICE: [test1 ~~* test1 3%] |
| 85 | +NOTICE: ['test1', 'test2'] |
| 86 | +NOTICE: UPDATING: test1 3 1 with [('test1', 'test'), ('test2', 'test2 1 1')] |
| 87 | +NOTICE: UPDATING: test1 3 4 with [('test1', 'test'), ('test2', 'test2 1 4')] |
| 88 | +NOTICE: UPDATING: test1 3 7 with [('test1', 'test'), ('test2', 'test2 1 7')] |
| 89 | +NOTICE: UPDATING: test1 3 10 with [('test1', 'test'), ('test2', 'test2 1 10')] |
| 90 | +NOTICE: UPDATING: test1 3 13 with [('test1', 'test'), ('test2', 'test2 1 13')] |
| 91 | +NOTICE: UPDATING: test1 3 16 with [('test1', 'test'), ('test2', 'test2 1 16')] |
| 92 | +NOTICE: UPDATING: test1 3 19 with [('test1', 'test'), ('test2', 'test2 1 19')] |
| 93 | +NOTICE: PRECOMMIT |
| 94 | +NOTICE: COMMIT |
| 95 | + test1 |
| 96 | +--------------- |
| 97 | + UPDATED: test |
| 98 | + UPDATED: test |
| 99 | + UPDATED: test |
| 100 | + UPDATED: test |
| 101 | + UPDATED: test |
| 102 | + UPDATED: test |
| 103 | + UPDATED: test |
| 104 | +(7 rows) |
| 105 | + |
| 106 | +delete from testmulticorn_write where test1 = 'test1 1 0' returning test2, test1; |
| 107 | +NOTICE: BEGIN |
| 108 | +NOTICE: [test1 = test1 1 0] |
| 109 | +NOTICE: ['test1', 'test2'] |
| 110 | +NOTICE: DELETING: test1 1 0 |
| 111 | +NOTICE: PRECOMMIT |
| 112 | +NOTICE: COMMIT |
| 113 | + test2 | test1 |
| 114 | +-----------+----------- |
| 115 | + test2 2 0 | test1 1 0 |
| 116 | +(1 row) |
| 117 | + |
| 118 | +DROP foreign table testmulticorn_write; |
| 119 | +-- Now test with another column |
| 120 | +CREATE foreign table testmulticorn_write( |
| 121 | + test1 character varying, |
| 122 | + test2 character varying |
| 123 | +) server multicorn_srv options ( |
| 124 | + option1 'option1', |
| 125 | + row_id_column 'test2' |
| 126 | +); |
| 127 | +insert into testmulticorn_write(test1, test2) VALUES ('test', 'test2'); |
| 128 | +NOTICE: [('option1', 'option1'), ('row_id_column', 'test2'), ('usermapping', 'test')] |
| 129 | +NOTICE: [('test1', 'character varying'), ('test2', 'character varying')] |
| 130 | +NOTICE: INSERTING: [('test1', 'test'), ('test2', 'test2')] |
| 131 | +update testmulticorn_write set test1 = 'test' where test1 ilike 'test1 3%'; |
| 132 | +NOTICE: [test1 ~~* test1 3%] |
| 133 | +NOTICE: ['test1', 'test2'] |
| 134 | +NOTICE: UPDATING: test2 1 1 with [('test1', 'test'), ('test2', 'test2 1 1')] |
| 135 | +NOTICE: UPDATING: test2 1 4 with [('test1', 'test'), ('test2', 'test2 1 4')] |
| 136 | +NOTICE: UPDATING: test2 1 7 with [('test1', 'test'), ('test2', 'test2 1 7')] |
| 137 | +NOTICE: UPDATING: test2 1 10 with [('test1', 'test'), ('test2', 'test2 1 10')] |
| 138 | +NOTICE: UPDATING: test2 1 13 with [('test1', 'test'), ('test2', 'test2 1 13')] |
| 139 | +NOTICE: UPDATING: test2 1 16 with [('test1', 'test'), ('test2', 'test2 1 16')] |
| 140 | +NOTICE: UPDATING: test2 1 19 with [('test1', 'test'), ('test2', 'test2 1 19')] |
| 141 | +delete from testmulticorn_write where test2 = 'test2 2 0'; |
| 142 | +NOTICE: [test2 = test2 2 0] |
| 143 | +NOTICE: ['test2'] |
| 144 | +NOTICE: DELETING: test2 2 0 |
| 145 | +update testmulticorn_write set test2 = 'test' where test2 = 'test2 1 1'; |
| 146 | +NOTICE: [test2 = test2 1 1] |
| 147 | +NOTICE: ['test1', 'test2'] |
| 148 | +NOTICE: UPDATING: test2 1 1 with [('test1', 'test1 3 1'), ('test2', 'test')] |
| 149 | +DROP foreign table testmulticorn_write; |
| 150 | +-- Now test with other types |
| 151 | +CREATE foreign table testmulticorn_write( |
| 152 | + test1 date, |
| 153 | + test2 timestamp |
| 154 | +) server multicorn_srv options ( |
| 155 | + option1 'option1', |
| 156 | + row_id_column 'test2', |
| 157 | + test_type 'date' |
| 158 | +); |
| 159 | +insert into testmulticorn_write(test1, test2) VALUES ('2012-01-01', '2012-01-01 00:00:00'); |
| 160 | +NOTICE: [('option1', 'option1'), ('row_id_column', 'test2'), ('test_type', 'date'), ('usermapping', 'test')] |
| 161 | +NOTICE: [('test1', 'date'), ('test2', 'timestamp without time zone')] |
| 162 | +NOTICE: INSERTING: [('test1', datetime.date(2012, 1, 1)), ('test2', datetime.datetime(2012, 1, 1, 0, 0))] |
| 163 | +delete from testmulticorn_write where test2 > '2011-12-03'; |
| 164 | +NOTICE: [test2 > 2011-12-03 00:00:00] |
| 165 | +NOTICE: ['test2'] |
| 166 | +NOTICE: DELETING: 2011-12-03 14:30:25 |
| 167 | +update testmulticorn_write set test1 = date_trunc('day', test1) where test2 = '2011-09-03 14:30:25'; |
| 168 | +NOTICE: [test2 = 2011-09-03 14:30:25] |
| 169 | +NOTICE: ['test1', 'test2'] |
| 170 | +NOTICE: UPDATING: 2011-09-03 14:30:25 with [('test1', datetime.date(2011, 9, 2)), ('test2', datetime.datetime(2011, 9, 3, 14, 30, 25))] |
| 171 | +DROP foreign table testmulticorn_write; |
| 172 | +-- Test with unknown column |
| 173 | +CREATE foreign table testmulticorn_write( |
| 174 | + test1 date, |
| 175 | + test2 timestamp |
| 176 | +) server multicorn_srv options ( |
| 177 | + option1 'option1', |
| 178 | + row_id_column 'teststuff', |
| 179 | + test_type 'date' |
| 180 | +); |
| 181 | +delete from testmulticorn_write; |
| 182 | +NOTICE: [('option1', 'option1'), ('row_id_column', 'teststuff'), ('test_type', 'date'), ('usermapping', 'test')] |
| 183 | +NOTICE: [('test1', 'date'), ('test2', 'timestamp without time zone')] |
| 184 | +ERROR: The rowid attribute does not exist |
| 185 | +DROP USER MAPPING FOR current_user SERVER multicorn_srv; |
| 186 | +DROP EXTENSION multicorn cascade; |
| 187 | +NOTICE: drop cascades to 3 other objects |
| 188 | +DETAIL: drop cascades to server multicorn_srv |
| 189 | +drop cascades to foreign table testmulticorn |
| 190 | +drop cascades to foreign table testmulticorn_write |
0 commit comments