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

Commite67ff6b

Browse files
committed
fmgr interface mopup work. Use new DatumGetBool and BoolGetDatum
macros where appropriate (the code used to have several different waysof doing that, including Int32, Int8, UInt8, ...). Remove last fewreferences to float32 and float64 typedefs --- it's all float4/float8now. The typedefs themselves should probably stay in c.h for a releaseor two, though, to avoid breaking user-written C functions.
1 parentb503cbe commite67ff6b

File tree

8 files changed

+68
-59
lines changed

8 files changed

+68
-59
lines changed

‎doc/src/sgml/xfunc.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.17 2000/05/27 18:18:31 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.18 2000/08/21 17:22:36 tgl Exp $
33
-->
44

55
<chapter id="xfunc">
@@ -499,12 +499,12 @@ SELECT clean_EMP();
499499
</row>
500500
<row>
501501
<entry>float4</entry>
502-
<entry>float32 or(float4 *)</entry>
502+
<entry>(float4 *)</entry>
503503
<entry>include/c.h or include/postgres.h</entry>
504504
</row>
505505
<row>
506506
<entry>float8</entry>
507-
<entry>float64 or(float8 *)</entry>
507+
<entry>(float8 *)</entry>
508508
<entry>include/c.h or include/postgres.h</entry>
509509
</row>
510510
<row>

‎src/backend/catalog/pg_operator.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.50 2000/05/28 17:55:54 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.51 2000/08/21 17:22:35 tgl Exp $
1212
*
1313
* NOTES
1414
* these routines moved here from commands/define.c and somewhat cleaned up.
@@ -262,10 +262,10 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
262262
namestrcpy(&oname,operatorName);
263263
values[i++]=NameGetDatum(&oname);
264264
values[i++]=Int32GetDatum(GetUserId());
265-
values[i++]=(Datum) (uint16)0;
266-
values[i++]=(Datum)'b';/* assume it's binary */
267-
values[i++]=(Datum) (bool)0;
268-
values[i++]=(Datum) (bool)0;
265+
values[i++]=UInt16GetDatum(0);
266+
values[i++]=CharGetDatum('b');/* assume it's binary */
267+
values[i++]=BoolGetDatum(false);
268+
values[i++]=BoolGetDatum(false);
269269
values[i++]=ObjectIdGetDatum(leftObjectId);/* <-- left oid */
270270
values[i++]=ObjectIdGetDatum(rightObjectId);/* <-- right oid */
271271
values[i++]=ObjectIdGetDatum(InvalidOid);
@@ -648,9 +648,9 @@ OperatorDef(char *operatorName,
648648
values[i++]=NameGetDatum(&oname);
649649
values[i++]=Int32GetDatum(GetUserId());
650650
values[i++]=UInt16GetDatum(precedence);
651-
values[i++]=leftTypeName ? (rightTypeName ?'b' :'r') :'l';
652-
values[i++]=Int8GetDatum(isLeftAssociative);
653-
values[i++]=Int8GetDatum(canHash);
651+
values[i++]=CharGetDatum(leftTypeName ? (rightTypeName ?'b' :'r') :'l');
652+
values[i++]=BoolGetDatum(isLeftAssociative);
653+
values[i++]=BoolGetDatum(canHash);
654654
values[i++]=ObjectIdGetDatum(leftTypeId);
655655
values[i++]=ObjectIdGetDatum(rightTypeId);
656656

‎src/backend/catalog/pg_proc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.46 2000/07/05 23:11:07 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.47 2000/08/21 17:22:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -295,14 +295,14 @@ ProcedureCreate(char *procedureName,
295295
values[i++]=Int32GetDatum(GetUserId());
296296
values[i++]=ObjectIdGetDatum(languageObjectId);
297297
/* XXX isinherited is always false for now */
298-
values[i++]=Int8GetDatum((bool)false);
299-
values[i++]=Int8GetDatum(trusted);
300-
values[i++]=Int8GetDatum(canCache);
301-
values[i++]=Int8GetDatum(isStrict);
298+
values[i++]=BoolGetDatum(false);
299+
values[i++]=BoolGetDatum(trusted);
300+
values[i++]=BoolGetDatum(canCache);
301+
values[i++]=BoolGetDatum(isStrict);
302302
values[i++]=UInt16GetDatum(parameterCount);
303-
values[i++]=Int8GetDatum(returnsSet);
303+
values[i++]=BoolGetDatum(returnsSet);
304304
values[i++]=ObjectIdGetDatum(typeObjectId);
305-
values[i++]=(Datum)typev;
305+
values[i++]=PointerGetDatum(typev);
306306
values[i++]=Int32GetDatum(byte_pct);/* probyte_pct */
307307
values[i++]=Int32GetDatum(perbyte_cpu);/* properbyte_cpu */
308308
values[i++]=Int32GetDatum(percall_cpu);/* propercall_cpu */

‎src/backend/catalog/pg_type.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.54 2000/07/05 23:11:07 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.55 2000/08/21 17:22:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -177,17 +177,17 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
177177
values[i++]=Int16GetDatum(0);/* 3 */
178178
values[i++]=Int16GetDatum(0);/* 4 */
179179
values[i++]=BoolGetDatum(false);/* 5 */
180-
values[i++]=BoolGetDatum(false);/* 6 */
180+
values[i++]=CharGetDatum(0);/* 6 */
181181
values[i++]=BoolGetDatum(false);/* 7 */
182-
values[i++]=BoolGetDatum(false);/* 8 */
182+
values[i++]=CharGetDatum(0);/* 8 */
183183
values[i++]=ObjectIdGetDatum(InvalidOid);/* 9 */
184184
values[i++]=ObjectIdGetDatum(InvalidOid);/* 10 */
185185
values[i++]=ObjectIdGetDatum(InvalidOid);/* 11 */
186186
values[i++]=ObjectIdGetDatum(InvalidOid);/* 12 */
187187
values[i++]=ObjectIdGetDatum(InvalidOid);/* 13 */
188188
values[i++]=ObjectIdGetDatum(InvalidOid);/* 14 */
189-
values[i++]=CharGetDatum('p');/* 15 */
190-
values[i++]=CharGetDatum('i');/* 16 */
189+
values[i++]=CharGetDatum('i');/* 15 */
190+
values[i++]=CharGetDatum('p');/* 16 */
191191
values[i++]=DirectFunctionCall1(textin,
192192
CStringGetDatum(typeName));/* 17 */
193193

@@ -370,16 +370,16 @@ TypeCreate(char *typeName,
370370
*/
371371
i=0;
372372
namestrcpy(&name,typeName);
373-
values[i++]=NameGetDatum(&name);/* 1 */
374-
values[i++]=(Datum)GetUserId();/* 2 */
375-
values[i++]=(Datum)internalSize;/* 3 */
376-
values[i++]=(Datum)externalSize;/* 4 */
377-
values[i++]=(Datum)passedByValue;/* 5 */
378-
values[i++]=(Datum)typeType;/* 6 */
379-
values[i++]=(Datum) (bool)1;/* 7 */
380-
values[i++]=(Datum)typDelim;/* 8 */
381-
values[i++]=(Datum)(typeType=='c' ?relationOid :InvalidOid);/* 9 */
382-
values[i++]=(Datum)elementObjectId;/* 10 */
373+
values[i++]=NameGetDatum(&name);/* 1 */
374+
values[i++]=Int32GetDatum(GetUserId());/* 2 */
375+
values[i++]=Int16GetDatum(internalSize);/* 3 */
376+
values[i++]=Int16GetDatum(externalSize);/* 4 */
377+
values[i++]=BoolGetDatum(passedByValue);/* 5 */
378+
values[i++]=CharGetDatum(typeType);/* 6 */
379+
values[i++]=BoolGetDatum(true);/* 7 */
380+
values[i++]=CharGetDatum(typDelim);/* 8 */
381+
values[i++]=ObjectIdGetDatum(typeType=='c' ?relationOid :InvalidOid);/* 9 */
382+
values[i++]=ObjectIdGetDatum(elementObjectId);/* 10 */
383383

384384
procs[0]=inputProcedure;
385385
procs[1]=outputProcedure;
@@ -438,20 +438,20 @@ TypeCreate(char *typeName,
438438
func_error("TypeCreate",procname,1,argList,NULL);
439439
}
440440

441-
values[i++]=(Datum)tup->t_data->t_oid;/* 11 - 14 */
441+
values[i++]=ObjectIdGetDatum(tup->t_data->t_oid);/* 11 - 14 */
442442
}
443443

444444
/* ----------------
445445
* set default alignment
446446
* ----------------
447447
*/
448-
values[i++]=(Datum)alignment;/* 15 */
448+
values[i++]=CharGetDatum(alignment);/* 15 */
449449

450450
/* ----------------
451451
*set default storage for TOAST
452452
* ----------------
453453
*/
454-
values[i++]=(Datum)storage;/* 16 */
454+
values[i++]=CharGetDatum(storage);/* 16 */
455455

456456
/* ----------------
457457
*initialize the default value for this type.

‎src/backend/commands/analyze.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.4 2000/08/06 04:40:08 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.5 2000/08/21 17:22:32 tgl Exp $
1212
*
1313
1414
*-------------------------------------------------------------------------
@@ -436,8 +436,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
436436

437437
if (VacAttrStatsEqValid(stats))
438438
{
439-
float32dataselratio;/* average ratio of rows selected
440-
* for a random constant */
439+
float4selratio;/* average ratio of rows selected
440+
* for a random constant */
441441

442442
/* Compute disbursion */
443443
if (stats->nonnull_cnt==0&&stats->null_cnt==0)

‎src/backend/commands/command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.94 2000/08/04 04:16:06 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.95 2000/08/21 17:22:32 tgl Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -614,7 +614,7 @@ AlterTableAlterColumn(const char *relationName,
614614
Int16GetDatum(attnum));
615615
ScanKeyEntryInitialize(&scankeys[2],0x0,
616616
Anum_pg_attribute_atthasdef,F_BOOLEQ,
617-
Int32GetDatum(TRUE));
617+
BoolGetDatum(true));
618618

619619
scan=heap_beginscan(attr_rel, false,SnapshotNow,3,scankeys);
620620
AssertState(scan!=NULL);

‎src/backend/optimizer/util/clauses.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.71 2000/08/13 02:50:10 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.72 2000/08/21 17:22:34 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHORDATEMAJOR EVENT
@@ -353,7 +353,7 @@ make_ands_implicit(Expr *clause)
353353
returnclause->args;
354354
elseif (IsA(clause,Const)&&
355355
!((Const*)clause)->constisnull&&
356-
DatumGetInt32(((Const*)clause)->constvalue))
356+
DatumGetBool(((Const*)clause)->constvalue))
357357
returnNIL;/* constant TRUE input -> NIL list */
358358
else
359359
returnlcons(clause,NIL);
@@ -1111,12 +1111,15 @@ eval_const_expressions_mutator(Node *node, void *context)
11111111
caseOR_EXPR:
11121112
{
11131113

1114-
/*
1115-
* OR arguments are handled as follows: non constant:
1116-
* keep FALSE: drop (does not affect result) TRUE:
1117-
* force result to TRUE NULL: keep only one We keep
1118-
* one NULL input because ExecEvalOr returns NULL when
1119-
* no input is TRUE and at least one is NULL.
1114+
/*----------
1115+
* OR arguments are handled as follows:
1116+
*non constant: keep
1117+
*FALSE: drop (does not affect result)
1118+
*TRUE: force result to TRUE
1119+
*NULL: keep only one
1120+
* We keep one NULL input because ExecEvalOr returns NULL
1121+
* when no input is TRUE and at least one is NULL.
1122+
*----------
11201123
*/
11211124
List*newargs=NIL;
11221125
List*arg;
@@ -1133,7 +1136,7 @@ eval_const_expressions_mutator(Node *node, void *context)
11331136
const_input= (Const*)lfirst(arg);
11341137
if (const_input->constisnull)
11351138
haveNull= true;
1136-
elseif (DatumGetInt32(const_input->constvalue))
1139+
elseif (DatumGetBool(const_input->constvalue))
11371140
forceTrue= true;
11381141
/* otherwise, we can drop the constant-false input */
11391142
}
@@ -1161,12 +1164,15 @@ eval_const_expressions_mutator(Node *node, void *context)
11611164
caseAND_EXPR:
11621165
{
11631166

1164-
/*
1165-
* AND arguments are handled as follows: non constant:
1166-
* keep TRUE: drop (does not affect result) FALSE:
1167-
* force result to FALSE NULL: keep only one We keep
1168-
* one NULL input because ExecEvalAnd returns NULL
1167+
/*----------
1168+
* AND arguments are handled as follows:
1169+
*non constant: keep
1170+
*TRUE: drop (does not affect result)
1171+
*FALSE: force result to FALSE
1172+
*NULL: keep only one
1173+
* We keep one NULL input because ExecEvalAnd returns NULL
11691174
* when no input is FALSE and at least one is NULL.
1175+
*----------
11701176
*/
11711177
List*newargs=NIL;
11721178
List*arg;
@@ -1183,7 +1189,7 @@ eval_const_expressions_mutator(Node *node, void *context)
11831189
const_input= (Const*)lfirst(arg);
11841190
if (const_input->constisnull)
11851191
haveNull= true;
1186-
elseif (!DatumGetInt32(const_input->constvalue))
1192+
elseif (!DatumGetBool(const_input->constvalue))
11871193
forceFalse= true;
11881194
/* otherwise, we can drop the constant-true input */
11891195
}
@@ -1217,7 +1223,7 @@ eval_const_expressions_mutator(Node *node, void *context)
12171223
if (const_input->constisnull)
12181224
returnMAKEBOOLCONST(false, true);
12191225
/* otherwise pretty easy */
1220-
returnMAKEBOOLCONST(!DatumGetInt32(const_input->constvalue),
1226+
returnMAKEBOOLCONST(!DatumGetBool(const_input->constvalue),
12211227
false);
12221228
caseSUBPLAN_EXPR:
12231229

@@ -1330,7 +1336,7 @@ eval_const_expressions_mutator(Node *node, void *context)
13301336
}
13311337
const_input= (Const*)casewhen->expr;
13321338
if (const_input->constisnull||
1333-
!DatumGetInt32(const_input->constvalue))
1339+
!DatumGetBool(const_input->constvalue))
13341340
continue;/* drop alternative with FALSE condition */
13351341

13361342
/*

‎src/include/c.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: c.h,v 1.80 2000/07/17 04:35:55 tgl Exp $
11+
* $Id: c.h,v 1.81 2000/08/21 17:22:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -186,6 +186,9 @@ typedef unsigned int uint32;/* == 32 bits */
186186
*
187187
*Since sizeof(floatN) may be > sizeof(char *), always pass
188188
*floatN by reference.
189+
*
190+
* XXX: these typedefs are now deprecated in favor of float4 and float8.
191+
* They will eventually go away.
189192
*/
190193
typedeffloatfloat32data;
191194
typedefdoublefloat64data;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp