PostgreSQL Source Code: src/backend/utils/adt/bool.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

17

18#include <ctype.h>

19

23

24

25

26

27

28

29

30bool

32{

34}

35

36bool

38{

39

41 {

42 case 't':

43 case 'T':

45 {

46 if (result)

47 *result = true;

48 return true;

49 }

50 break;

51 case 'f':

52 case 'F':

54 {

55 if (result)

56 *result = false;

57 return true;

58 }

59 break;

60 case 'y':

61 case 'Y':

63 {

64 if (result)

65 *result = true;

66 return true;

67 }

68 break;

69 case 'n':

70 case 'N':

72 {

73 if (result)

74 *result = false;

75 return true;

76 }

77 break;

78 case 'o':

79 case 'O':

80

82 {

83 if (result)

84 *result = true;

85 return true;

86 }

88 {

89 if (result)

90 *result = false;

91 return true;

92 }

93 break;

94 case '1':

95 if (len == 1)

96 {

97 if (result)

98 *result = true;

99 return true;

100 }

101 break;

102 case '0':

103 if (len == 1)

104 {

105 if (result)

106 *result = false;

107 return true;

108 }

109 break;

110 default:

111 break;

112 }

113

114 if (result)

115 *result = false;

116 return false;

117}

118

119

120

121

122

123

124

125

128{

130 const char *str;

131 size_t len;

132 bool result;

133

134

135

136

137 str = in_str;

138 while (isspace((unsigned char) *str))

140

142 while (len > 0 && isspace((unsigned char) str[len - 1]))

144

147

149 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),

150 errmsg("invalid input syntax for type %s: \"%s\"",

151 "boolean", in_str)));

152}

153

154

155

156

159{

161 char *result = (char *) palloc(2);

162

163 result[0] = (b) ? 't' : 'f';

164 result[1] = '\0';

166}

167

168

169

170

171

172

173

176{

178 int ext;

179

182}

183

184

185

186

189{

192

196}

197

198

199

200

201

202

203

206{

208 const char *str;

209

210 if (arg1)

211 str = "true";

212 else

213 str = "false";

214

216}

217

218

219

220

221

222

225{

228

230}

231

234{

237

239}

240

243{

246

248}

249

252{

255

257}

258

261{

264

266}

267

270{

273

275}

276

279{

281}

282

285{

287}

288

289

290

291

292

293

294

295

296

297

298

301{

303}

304

305

306

307

308

309

310

313{

315}

316

318{

320 int64 aggtrue;

322

325{

328

330 elog(ERROR, "aggregate function called in non-aggregate context");

331

334 state->aggcount = 0;

335 state->aggtrue = 0;

336

338}

339

342{

344

346

347

348 if (state == NULL)

350

352 {

353 state->aggcount++;

355 state->aggtrue++;

356 }

357

359}

360

363{

365

367

368

369 if (state == NULL)

370 elog(ERROR, "bool_accum_inv called with NULL state");

371

373 {

374 state->aggcount--;

376 state->aggtrue--;

377 }

378

380}

381

384{

386

388

389

390 if (state == NULL || state->aggcount == 0)

392

393

395}

396

399{

401

403

404

405 if (state == NULL || state->aggcount == 0)

407

408

410}

Datum boolge(PG_FUNCTION_ARGS)

Datum boolor_statefunc(PG_FUNCTION_ARGS)

Datum boolle(PG_FUNCTION_ARGS)

Datum boollt(PG_FUNCTION_ARGS)

bool parse_bool(const char *value, bool *result)

Datum boolin(PG_FUNCTION_ARGS)

Datum hashbool(PG_FUNCTION_ARGS)

Datum hashboolextended(PG_FUNCTION_ARGS)

Datum boolgt(PG_FUNCTION_ARGS)

Datum boolrecv(PG_FUNCTION_ARGS)

Datum boolsend(PG_FUNCTION_ARGS)

static BoolAggState * makeBoolAggState(FunctionCallInfo fcinfo)

Datum boolout(PG_FUNCTION_ARGS)

Datum booland_statefunc(PG_FUNCTION_ARGS)

Datum bool_alltrue(PG_FUNCTION_ARGS)

Datum booltext(PG_FUNCTION_ARGS)

Datum booleq(PG_FUNCTION_ARGS)

Datum bool_accum_inv(PG_FUNCTION_ARGS)

Datum boolne(PG_FUNCTION_ARGS)

Datum bool_anytrue(PG_FUNCTION_ARGS)

Datum bool_accum(PG_FUNCTION_ARGS)

bool parse_bool_with_len(const char *value, size_t len, bool *result)

struct BoolAggState BoolAggState

int errcode(int sqlerrcode)

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

#define ereturn(context, dummy_value,...)

#define PG_RETURN_BYTEA_P(x)

#define PG_GETARG_POINTER(n)

#define PG_RETURN_CSTRING(x)

#define PG_GETARG_CSTRING(n)

#define PG_GETARG_INT64(n)

#define PG_RETURN_TEXT_P(x)

#define PG_GETARG_BOOL(n)

#define PG_RETURN_POINTER(x)

#define PG_RETURN_BOOL(x)

static Datum hash_uint32(uint32 k)

static Datum hash_uint32_extended(uint32 k, uint64 seed)

void * MemoryContextAlloc(MemoryContext context, Size size)

int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)

int pg_strncasecmp(const char *s1, const char *s2, size_t n)

void pq_begintypsend(StringInfo buf)

int pq_getmsgbyte(StringInfo msg)

bytea * pq_endtypsend(StringInfo buf)

static void pq_sendbyte(StringInfo buf, uint8 byt)

StringInfoData * StringInfo

text * cstring_to_text(const char *s)