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

Commit43dbd76

Browse files
committed
PGPRO-2118: Check existance of hash and cmp functions before initializing a variable
1 parenta5f6a7e commit43dbd76

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

‎pg_variables_record.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
7575

7676
Assert(variable->typid==RECORDOID);
7777

78+
/* First get hash and match functions for key type. */
79+
keyid=GetTupleDescAttr(tupdesc,0)->atttypid;
80+
typentry=lookup_type_cache(keyid,
81+
TYPECACHE_HASH_PROC_FINFO |
82+
TYPECACHE_CMP_PROC_FINFO);
83+
84+
if (!OidIsValid(typentry->hash_proc_finfo.fn_oid))
85+
ereport(ERROR,
86+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
87+
errmsg("could not identify a hash function for type %s",
88+
format_type_be(keyid))));
89+
90+
if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid))
91+
ereport(ERROR,
92+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
93+
errmsg("could not identify a matching function for type %s",
94+
format_type_be(keyid))));
95+
96+
/* Initialize the record */
97+
7898
sprintf(hash_name,"Records hash for variable \"%s\"",GetName(variable));
7999

80100
topctx=variable->is_transactional ?
@@ -109,24 +129,6 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
109129
HASH_ELEM |HASH_CONTEXT |
110130
HASH_FUNCTION |HASH_COMPARE);
111131

112-
/* Get hash and match functions for key type. */
113-
keyid=GetTupleDescAttr(record->tupdesc,0)->atttypid;
114-
typentry=lookup_type_cache(keyid,
115-
TYPECACHE_HASH_PROC_FINFO |
116-
TYPECACHE_CMP_PROC_FINFO);
117-
118-
if (!OidIsValid(typentry->hash_proc_finfo.fn_oid))
119-
ereport(ERROR,
120-
(errcode(ERRCODE_UNDEFINED_FUNCTION),
121-
errmsg("could not identify a hash function for type %s",
122-
format_type_be(keyid))));
123-
124-
if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid))
125-
ereport(ERROR,
126-
(errcode(ERRCODE_UNDEFINED_FUNCTION),
127-
errmsg("could not identify a matching function for type %s",
128-
format_type_be(keyid))));
129-
130132
fmgr_info(typentry->hash_proc_finfo.fn_oid,&record->hash_proc);
131133
fmgr_info(typentry->cmp_proc_finfo.fn_oid,&record->cmp_proc);
132134

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp