PostgreSQL Source Code: src/backend/utils/cache/partcache.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

35

36

39

40

41

42

43

44

45

46

47

48

49

52{

53 if (rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)

54 return NULL;

55

58

60}

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77static void

79{

82 bool isnull;

83 int i;

91 oldcxt;

93

96

98 elog(ERROR, "cache lookup failed for partition key of relation %u",

100

102 "partition key",

106

109

110

112 key->strategy = form->partstrat;

113 key->partnatts = form->partnatts;

114

115

119 elog(ERROR, "invalid partition strategy \"%c\"", key->strategy);

120

121

122

123

124

125

126 attrs = form->partattrs.values;

127

128

129

131 Anum_pg_partitioned_table_partclass);

133

134

136 Anum_pg_partitioned_table_partcollation);

138

139

141 Anum_pg_partitioned_table_partexprs, &isnull);

142 if (!isnull)

143 {

144 char *exprString;

146

149 pfree(exprString);

150

151

152

153

154

155

156

157

158

159

162

166 }

167

168

174

179 key->parttypbyval = (bool *) palloc0(key->partnatts * sizeof(bool));

180 key->parttypalign = (char *) palloc0(key->partnatts * sizeof(char));

183

184

187

188

189 memcpy(key->partattrs, attrs, key->partnatts * sizeof(int16));

191 for (i = 0; i < key->partnatts; i++)

192 {

196 Oid funcid;

197

198

202 elog(ERROR, "cache lookup failed for opclass %u", opclass->values[i]);

203

205 key->partopfamily[i] = opclassform->opcfamily;

206 key->partopcintype[i] = opclassform->opcintype;

207

208

210 opclassform->opcintype,

211 opclassform->opcintype,

212 procnum);

215 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),

216 errmsg("operator class \"%s\" of access method %s is missing support function %d for type %s",

217 NameStr(opclassform->opcname),

219 "hash" : "btree",

220 procnum,

222

224

225

226 key->partcollation[i] = collation->values[i];

227

228

229 if (attno != 0)

230 {

232

233 key->parttypid[i] = att->atttypid;

234 key->parttypmod[i] = att->atttypmod;

235 key->parttypcoll[i] = att->attcollation;

236 }

237 else

238 {

239 if (partexprs_item == NULL)

240 elog(ERROR, "wrong number of partition key expressions");

241

245

246 partexprs_item = lnext(key->partexprs, partexprs_item);

247 }

249 &key->parttyplen[i],

250 &key->parttypbyval[i],

251 &key->parttypalign[i]);

252

254 }

255

257

258

261

262

263

264

265

269}

270

271

272

273

274

275

278{

279

280 if (!rel->rd_rel->relispartition)

281 return NIL;

282

284}

285

286

287

288

289

290

291

292

293

294

295

296

297

300{

301 Expr *result = NULL;

302

303

305 {

307 List *and_args;

308

310

311

312 if (and_args == NIL)

313 result = NULL;

316 else

318

319

321 }

322

323 return result;

324}

325

326

327

328

329

330

331

332

333

334

335

338{

341 Datum boundDatum;

342 bool isnull;

344 *result = NIL;

345 Oid parentrelid;

347

348

350

351

354

355

356

357

358

359

360

363

364

368 elog(ERROR, "cache lookup failed for relation %u",

370

372 Anum_pg_class_relpartbound,

373 &isnull);

374 if (!isnull)

375 {

377

380

382 }

383

385

386

387 if (parent->rd_rel->relispartition)

389 else

390 result = my_qual;

391

392

393

394

395

396

397

399

400

403

404

405

406

407

408

409

410

411

412 if (result != NIL)

413 {

415 "partition constraint",

422 }

423 else

426

427

429

430

431 return result;

432}

#define TextDatumGetCString(d)

#define OidIsValid(objectId)

Node * eval_const_expressions(PlannerInfo *root, Node *node)

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereport(elevel,...)

void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)

char * format_type_be(Oid type_oid)

#define HASHEXTENDED_PROC

Assert(PointerIsAligned(start, uint64))

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

List * list_concat(List *list1, const List *list2)

bool get_rel_relispartition(Oid relid)

void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)

Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)

Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)

void * MemoryContextAllocZero(MemoryContext context, Size size)

void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)

void pfree(void *pointer)

void * palloc0(Size size)

MemoryContext CurTransactionContext

MemoryContext CacheMemoryContext

#define AllocSetContextCreate

#define ALLOCSET_SMALL_SIZES

#define MemoryContextCopyAndSetIdentifier(cxt, id)

Oid exprType(const Node *expr)

int32 exprTypmod(const Node *expr)

Oid exprCollation(const Node *expr)

void fix_opfuncids(Node *node)

#define castNode(_type_, nodeptr)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

@ PARTITION_STRATEGY_HASH

@ PARTITION_STRATEGY_LIST

@ PARTITION_STRATEGY_RANGE

List * get_qual_from_partbound(Relation parent, PartitionBoundSpec *spec)

List * RelationGetPartitionQual(Relation rel)

static List * generate_partition_qual(Relation rel)

static void RelationBuildPartitionKey(Relation relation)

Expr * get_partition_qual_relid(Oid relid)

PartitionKey RelationGetPartitionKey(Relation rel)

struct PartitionKeyData * PartitionKey

List * map_partition_varattnos(List *expr, int fromrel_varno, Relation to_rel, Relation from_rel)

Oid get_partition_parent(Oid relid, bool even_if_detached)

FormData_pg_attribute * Form_pg_attribute

static int list_length(const List *l)

static ListCell * list_head(const List *l)

static ListCell * lnext(const List *l, const ListCell *c)

FormData_pg_opclass * Form_pg_opclass

FormData_pg_partitioned_table * Form_pg_partitioned_table

static Datum ObjectIdGetDatum(Oid X)

static Pointer DatumGetPointer(Datum X)

void * stringToNode(const char *str)

#define RelationGetRelid(relation)

#define RelationGetRelationName(relation)

void relation_close(Relation relation, LOCKMODE lockmode)

Relation relation_open(Oid relationId, LOCKMODE lockmode)

void check_stack_depth(void)

MemoryContext rd_partkeycxt

MemoryContext rd_partcheckcxt

Oid values[FLEXIBLE_ARRAY_MEMBER]

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)

Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)

static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)