Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50a16e3

Browse files
committed
Use the right type OID after creating a shell type
Commita2e35b5 neglected to update the type OID to use furtherdown in DefineType when TypeShellMake was changed to returnObjectAddress instead of OID (it got it right in DefineRange, however.)This resulted in an internal error message being issued when looking upI/O functions.Author: Michael PaquierAlso add Asserts() to a couple of other places to ensure that the typeOID being used is as expected.
1 parent450fa1b commit50a16e3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎src/backend/commands/typecmds.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ DefineType(List *names, List *parameters)
215215
if (!OidIsValid(typoid))
216216
{
217217
address=TypeShellMake(typeName,typeNamespace,GetUserId());
218+
typoid=address.objectId;
218219
/* Make new shell type visible for modification below */
219220
CommandCounterIncrement();
220221

@@ -628,6 +629,7 @@ DefineType(List *names, List *parameters)
628629
0,/* Array Dimensions of typbasetype */
629630
false,/* Type NOT NULL */
630631
collation);/* type's collation */
632+
Assert(typoid==address.objectId);
631633

632634
/*
633635
* Create the array type that goes with it.
@@ -1505,7 +1507,7 @@ DefineRange(CreateRangeStmt *stmt)
15051507
0,/* Array dimensions of typbasetype */
15061508
false,/* Type NOT NULL */
15071509
InvalidOid);/* type's collation (ranges never have one) */
1508-
typoid=address.objectId;
1510+
Assert(typoid==address.objectId);
15091511

15101512
/* Create the entry in pg_range */
15111513
RangeCreate(typoid,rangeSubtype,rangeCollation,rangeSubOpclass,

‎src/test/regress/expected/create_type.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ ERROR: type "text_w_default" already exists
107107
DROP TYPE default_test_row CASCADE;
108108
NOTICE: drop cascades to function get_default_test()
109109
DROP TABLE default_test;
110+
-- Check type create with input/output incompatibility
111+
CREATE TYPE not_existing_type (INPUT = array_in,
112+
OUTPUT = array_out,
113+
ELEMENT = int,
114+
INTERNALLENGTH = 32);
115+
ERROR: function array_out(not_existing_type) does not exist
110116
-- Check usage of typmod with a user-defined type
111117
-- (we have borrowed numeric's typmod functions)
112118
CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail

‎src/test/regress/sql/create_type.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ DROP TYPE default_test_row CASCADE;
106106

107107
DROPTABLE default_test;
108108

109+
-- Check type create with input/output incompatibility
110+
CREATETYPEnot_existing_type (INPUT= array_in,
111+
OUTPUT= array_out,
112+
ELEMENT=int,
113+
INTERNALLENGTH=32);
114+
109115
-- Check usage of typmod with a user-defined type
110116
-- (we have borrowed numeric's typmod functions)
111117

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp