PostgreSQL Source Code: src/test/modules/plsample/plsample.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

17

24#include "utils/fmgrprotos.h"

27

29

31

34

35

36

37

40{

42

43

44

45

46

47

49 {

50

51

52

53

55 {

56

57

58

59

60

62 }

64 {

65

66

67

68

69

70

71

72 }

73 else

74 {

75

77 }

78 }

80 {

81 }

83

84 return retval;

85}

86

87

88

89

90

91

94{

98 bool isnull;

104 Oid *argtypes;

105 char **argnames;

106 char *argmodes;

109 Oid result_typioparam;

110 Oid prorettype;

112 int numargs;

113

114

118 elog(ERROR, "cache lookup failed for function %u",

119 fcinfo->flinfo->fn_oid);

120

121

122

123

124

127 ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);

128 if (isnull)

129 elog(ERROR, "could not find source text of function \"%s\"",

133 (errmsg("source text of function \"%s\": %s",

135

136

137

138

139

141 "PL/Sample function",

143

145 numargs = get_func_arg_info(pl_tuple, &argtypes, &argnames, &argmodes);

146

147

148

149

150

151 for (int i = 0; i < numargs; i++)

152 {

153 Oid argtype = pl_struct->proargtypes.values[i];

155

158 elog(ERROR, "cache lookup failed for type %u", argtype);

159

161 fmgr_info_cxt(type_struct->typoutput, &(arg_out_func[i]), proc_cxt);

163

166 (errmsg("argument: %d; name: %s; value: %s",

167 i, argnames[i], value)));

168 }

169

170

171 prorettype = pl_struct->prorettype;

173

174

175

176

177

178

179

180

181

182 if (prorettype != TEXTOID)

184

188 elog(ERROR, "cache lookup failed for type %u", prorettype);

191

192 fmgr_info_cxt(pg_type_entry->typinput, &result_in_func, proc_cxt);

194

197}

198

199

200

201

202

203

206{

208 char *string;

213 bool isnull;

217

218

220 elog(ERROR, "not called by trigger manager");

221

222

224

227

228

232 elog(ERROR, "cache lookup failed for function %u",

233 fcinfo->flinfo->fn_oid);

234

235

236

237

238

239

240

243 ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull);

244 if (isnull)

245 elog(ERROR, "could not find source text of function \"%s\"",

249 (errmsg("source text of function \"%s\": %s",

251

252

253

254

255

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

283 {

288

291

292

293

295 {

298 }

300 {

303 }

305 {

308 }

310 {

313 }

314 else

316

323 else

325

330 else

332

333

334

335

336

339 (errmsg("trigger arg[%i]: %s", i,

341 }

343 {

344

346 }

348

350 elog(ERROR, "SPI_finish() failed");

351

352 return rettup;

353}

#define PG_USED_FOR_ASSERTS_ONLY

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

#define ereport(elevel,...)

#define CALLED_AS_EVENT_TRIGGER(fcinfo)

Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)

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

char * OutputFunctionCall(FmgrInfo *flinfo, Datum val)

#define DirectFunctionCall1(func, arg1)

#define PG_RETURN_DATUM(x)

int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes)

Assert(PointerIsAligned(start, uint64))

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

if(TABLE==NULL||TABLE_index==NULL)

Oid getTypeIOParam(HeapTuple typeTuple)

char * pstrdup(const char *in)

void * palloc0(Size size)

MemoryContext TopMemoryContext

#define AllocSetContextCreate

#define ALLOCSET_SMALL_SIZES

FormData_pg_proc * Form_pg_proc

static rewind_source * source

FormData_pg_type * Form_pg_type

static Datum plsample_func_handler(PG_FUNCTION_ARGS)

PG_FUNCTION_INFO_V1(plsample_call_handler)

Datum plsample_call_handler(PG_FUNCTION_ARGS)

static HeapTuple plsample_trigger_handler(PG_FUNCTION_ARGS)

static Datum PointerGetDatum(const void *X)

static Datum ObjectIdGetDatum(Oid X)

static char * DatumGetCString(Datum X)

int SPI_register_trigger_data(TriggerData *tdata)

char * SPI_getnspname(Relation rel)

char * SPI_getrelname(Relation rel)

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

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

#define TRIGGER_FIRED_FOR_STATEMENT(event)

#define TRIGGER_FIRED_BY_DELETE(event)

#define TRIGGER_FIRED_BEFORE(event)

#define CALLED_AS_TRIGGER(fcinfo)

#define TRIGGER_FIRED_FOR_ROW(event)

#define TRIGGER_FIRED_AFTER(event)

#define TRIGGER_FIRED_BY_TRUNCATE(event)

#define TRIGGER_FIRED_BY_INSERT(event)

#define TRIGGER_FIRED_BY_UPDATE(event)

#define TRIGGER_FIRED_INSTEAD(event)

Datum textout(PG_FUNCTION_ARGS)