1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Fix dblink_build_sql_insert() and related functions to handle dropped

columns correctly.  In passing, get rid of some dead logic in the
underlying get_sql_insert() etc functions --- there is no caller that
will pass null value-arrays to them.

Per bug report from Robert Voinea.
This commit is contained in:
Tom Lane
2010-06-15 19:04:22 +00:00
parent 9486eeb714
commit 37d8570d4d
3 changed files with 102 additions and 33 deletions

View File

@ -395,3 +395,29 @@ DROP USER dblink_regression_test;
DROP USER MAPPING FOR public SERVER fdtest;
DROP SERVER fdtest;
DROP FOREIGN DATA WRAPPER postgresql;
-- test dropped columns in dblink_build_sql_insert, dblink_build_sql_update
CREATE TEMP TABLE test_dropped
(
col1 INT NOT NULL DEFAULT 111,
id SERIAL PRIMARY KEY,
col2 INT NOT NULL DEFAULT 112,
col2b INT NOT NULL DEFAULT 113
);
INSERT INTO test_dropped VALUES(default);
ALTER TABLE test_dropped
DROP COLUMN col1,
DROP COLUMN col2,
ADD COLUMN col3 VARCHAR(10) NOT NULL DEFAULT 'foo',
ADD COLUMN col4 INT NOT NULL DEFAULT 42;
SELECT dblink_build_sql_insert('test_dropped', '2', 1,
ARRAY['1'::TEXT], ARRAY['2'::TEXT]);
SELECT dblink_build_sql_update('test_dropped', '2', 1,
ARRAY['1'::TEXT], ARRAY['2'::TEXT]);
SELECT dblink_build_sql_delete('test_dropped', '2', 1,
ARRAY['2'::TEXT]);