mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix handling of pg_type.typdefault per bug report from Dave Blasby.
If there's anyone out there who's actually using datatype-defined default values, this will be an incompatible change in behavior ... but the old behavior was so broken that I doubt anyone was using it.
This commit is contained in:
@ -13,3 +13,28 @@ CREATE TYPE city_budget (
|
||||
output = int44out,
|
||||
element = int4
|
||||
);
|
||||
-- Test type-related default values (broken in releases before PG 7.2)
|
||||
CREATE TYPE int42 (
|
||||
internallength = 4,
|
||||
input = int4in,
|
||||
output = int4out,
|
||||
alignment = int4,
|
||||
default = 42,
|
||||
passedbyvalue
|
||||
);
|
||||
CREATE TYPE text_w_default (
|
||||
internallength = variable,
|
||||
input = textin,
|
||||
output = textout,
|
||||
alignment = int4,
|
||||
default = 'zippo'
|
||||
);
|
||||
CREATE TABLE default_test (f1 text_w_default, f2 int42);
|
||||
INSERT INTO default_test DEFAULT VALUES;
|
||||
SELECT * FROM default_test;
|
||||
f1 | f2
|
||||
-------+----
|
||||
zippo | 42
|
||||
(1 row)
|
||||
|
||||
DROP TABLE default_test;
|
||||
|
@ -16,3 +16,29 @@ CREATE TYPE city_budget (
|
||||
element = int4
|
||||
);
|
||||
|
||||
-- Test type-related default values (broken in releases before PG 7.2)
|
||||
|
||||
CREATE TYPE int42 (
|
||||
internallength = 4,
|
||||
input = int4in,
|
||||
output = int4out,
|
||||
alignment = int4,
|
||||
default = 42,
|
||||
passedbyvalue
|
||||
);
|
||||
|
||||
CREATE TYPE text_w_default (
|
||||
internallength = variable,
|
||||
input = textin,
|
||||
output = textout,
|
||||
alignment = int4,
|
||||
default = 'zippo'
|
||||
);
|
||||
|
||||
CREATE TABLE default_test (f1 text_w_default, f2 int42);
|
||||
|
||||
INSERT INTO default_test DEFAULT VALUES;
|
||||
|
||||
SELECT * FROM default_test;
|
||||
|
||||
DROP TABLE default_test;
|
||||
|
Reference in New Issue
Block a user