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

Commit8829bc2

Browse files
committed
Fix building for 434e6e1484418c55561914600de9e180fc408378
1 parent078d0ed commit8829bc2

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

‎pg_variables.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,11 +1385,17 @@ ensurePackagesHashExists()
13851385
if (packagesHash)
13861386
return;
13871387

1388+
#ifPG_VERSION_NUM >=110000
1389+
ModuleContext=AllocSetContextCreate(CacheMemoryContext,
1390+
"pg_variables memory context",
1391+
ALLOCSET_DEFAULT_SIZES);
1392+
#else
13881393
ModuleContext=AllocSetContextCreate(CacheMemoryContext,
13891394
"pg_variables memory context",
13901395
ALLOCSET_DEFAULT_MINSIZE,
13911396
ALLOCSET_DEFAULT_INITSIZE,
13921397
ALLOCSET_DEFAULT_MAXSIZE);
1398+
#endif
13931399

13941400
ctl.keysize=NAMEDATALEN;
13951401
ctl.entrysize=sizeof(HashPackageEntry);
@@ -1441,11 +1447,20 @@ getPackageByName(text* name, bool create, bool strict)
14411447

14421448
sprintf(hash_name,"Variables hash for package \"%s\"",key);
14431449

1450+
#ifPG_VERSION_NUM >=110000
1451+
package->hctx=AllocSetContextCreateExtended(ModuleContext,
1452+
hash_name,0,
1453+
ALLOCSET_DEFAULT_MINSIZE,
1454+
ALLOCSET_DEFAULT_INITSIZE,
1455+
ALLOCSET_DEFAULT_MAXSIZE);
1456+
#else
14441457
package->hctx=AllocSetContextCreate(ModuleContext,
14451458
hash_name,
14461459
ALLOCSET_DEFAULT_MINSIZE,
14471460
ALLOCSET_DEFAULT_INITSIZE,
14481461
ALLOCSET_DEFAULT_MAXSIZE);
1462+
#endif
1463+
14491464
oldcxt=MemoryContextSwitchTo(package->hctx);
14501465

14511466
ctl.keysize=NAMEDATALEN;

‎pg_variables.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#ifndef__PG_VARIABLES_H__
1111
#define__PG_VARIABLES_H__
1212

13+
#include"pg_config.h"
14+
1315
#include"access/htup.h"
1416
#include"access/tupdesc.h"
1517
#include"datatype/timestamp.h"
@@ -18,6 +20,13 @@
1820
#include"utils/numeric.h"
1921
#include"utils/jsonb.h"
2022

23+
/* Accessor for the i'th attribute of tupdesc. */
24+
#ifPG_VERSION_NUM>100000
25+
#defineGetTupleDescAttr(tupdesc,i) (TupleDescAttr(tupdesc, i))
26+
#else
27+
#defineGetTupleDescAttr(tupdesc,i) ((tupdesc)->attrs[(i)])
28+
#endif
29+
2130
/* initial number of packages hashes */
2231
#defineNUMPACKAGES 8
2332
#defineNUMVARIABLES 16

‎pg_variables_record.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,21 @@ init_attributes(HashVariableEntry *variable, TupleDesc tupdesc,
7979
sprintf(hash_name,"Records hash for variable \"%s\"",variable->name);
8080

8181
record=&(variable->value.record);
82+
83+
#ifPG_VERSION_NUM >=110000
84+
record->hctx=AllocSetContextCreateExtended(topctx,
85+
hash_name,0,
86+
ALLOCSET_DEFAULT_MINSIZE,
87+
ALLOCSET_DEFAULT_INITSIZE,
88+
ALLOCSET_DEFAULT_MAXSIZE);
89+
#else
8290
record->hctx=AllocSetContextCreate(topctx,
8391
hash_name,
8492
ALLOCSET_DEFAULT_MINSIZE,
8593
ALLOCSET_DEFAULT_INITSIZE,
8694
ALLOCSET_DEFAULT_MAXSIZE);
95+
#endif
96+
8797
oldcxt=MemoryContextSwitchTo(record->hctx);
8898
record->tupdesc=CreateTupleDescCopyConstr(tupdesc);
8999

@@ -99,7 +109,7 @@ init_attributes(HashVariableEntry *variable, TupleDesc tupdesc,
99109
HASH_FUNCTION |HASH_COMPARE);
100110

101111
/* Get hash and match functions for key type. */
102-
keyid=record->tupdesc->attrs[0]->atttypid;
112+
keyid=GetTupleDescAttr(record->tupdesc,0)->atttypid;
103113
typentry=lookup_type_cache(keyid,
104114
TYPECACHE_HASH_PROC_FINFO |
105115
TYPECACHE_CMP_PROC_FINFO);
@@ -142,8 +152,8 @@ check_attributes(HashVariableEntry *variable, TupleDesc tupdesc)
142152
/* Second, check columns type. */
143153
for (i=0;i<tupdesc->natts;i++)
144154
{
145-
Form_pg_attributeattr1=variable->value.record.tupdesc->attrs[i],
146-
attr2=tupdesc->attrs[i];
155+
Form_pg_attributeattr1=GetTupleDescAttr(variable->value.record.tupdesc,i),
156+
attr2=GetTupleDescAttr(tupdesc,i);
147157

148158
if ((attr1->atttypid!=attr2->atttypid)
149159
|| (attr1->attndims!=attr2->attndims)
@@ -163,7 +173,7 @@ check_record_key(HashVariableEntry *variable, Oid typid)
163173
{
164174
Assert(variable->typid==RECORDOID);
165175

166-
if (variable->value.record.tupdesc->attrs[0]->atttypid!=typid)
176+
if (GetTupleDescAttr(variable->value.record.tupdesc,0)->atttypid!=typid)
167177
ereport(ERROR,
168178
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
169179
errmsg("requested value type differs from variable \"%s\" "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp