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

Commit481487b

Browse files
committed
GetAttributeByName and GetAttributeByNum should be declared to return
Datum, not char*, for portability's sake.
1 parentd9eb7d8 commit481487b

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

‎src/backend/executor/execQual.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.79 2000/08/2403:29:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.80 2000/08/2423:34:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -502,13 +502,8 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull)
502502
*named attribute out of the tuple from the arg slot. User defined
503503
*C functions which take a tuple as an argument are expected
504504
*to use this. Ex: overpaid(EMP) might call GetAttributeByNum().
505-
*
506-
* XXX these two functions are misdeclared: they should be declared to
507-
* return Datum. They are not used anywhere in the backend proper, and
508-
* exist only for use by user-defined functions. Should we change their
509-
* definitions, at risk of breaking user code?
510505
*/
511-
char*
506+
Datum
512507
GetAttributeByNum(TupleTableSlot*slot,
513508
AttrNumberattrno,
514509
bool*isNull)
@@ -527,19 +522,20 @@ GetAttributeByNum(TupleTableSlot *slot,
527522
if (TupIsNull(slot))
528523
{
529524
*isNull= true;
530-
return (char*)NULL;
525+
return (Datum)0;
531526
}
532527

533528
retval=heap_getattr(slot->val,
534529
attrno,
535530
slot->ttc_tupleDescriptor,
536531
isNull);
537532
if (*isNull)
538-
return (char*)NULL;
539-
return (char*)retval;
533+
return (Datum)0;
534+
535+
returnretval;
540536
}
541537

542-
char*
538+
Datum
543539
GetAttributeByName(TupleTableSlot*slot,char*attname,bool*isNull)
544540
{
545541
AttrNumberattrno;
@@ -557,7 +553,7 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
557553
if (TupIsNull(slot))
558554
{
559555
*isNull= true;
560-
return (char*)NULL;
556+
return (Datum)0;
561557
}
562558

563559
tupdesc=slot->ttc_tupleDescriptor;
@@ -581,8 +577,9 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
581577
tupdesc,
582578
isNull);
583579
if (*isNull)
584-
return (char*)NULL;
585-
return (char*)retval;
580+
return (Datum)0;
581+
582+
returnretval;
586583
}
587584

588585
/*

‎src/include/executor/executor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: executor.h,v 1.49 2000/08/2403:29:10 tgl Exp $
10+
* $Id: executor.h,v 1.50 2000/08/2423:34:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -74,9 +74,9 @@ extern void ExecEndNode(Plan *node, Plan *parent);
7474
*/
7575
externDatumExecEvalParam(Param*expression,ExprContext*econtext,
7676
bool*isNull);
77-
externchar*GetAttributeByNum(TupleTableSlot*slot,AttrNumberattrno,
78-
bool*isNull);
79-
externchar*GetAttributeByName(TupleTableSlot*slot,char*attname,
77+
externDatumGetAttributeByNum(TupleTableSlot*slot,AttrNumberattrno,
78+
bool*isNull);
79+
externDatumGetAttributeByName(TupleTableSlot*slot,char*attname,
8080
bool*isNull);
8181
externDatumExecMakeFunctionResult(FunctionCachePtrfcache,
8282
List*arguments,

‎src/test/regress/regress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.43 2000/07/30 20:43:54 tgl Exp $
2+
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.44 2000/08/24 23:34:11 tgl Exp $
33
*/
44

55
#include<float.h>/* faked on sunos */
@@ -187,9 +187,9 @@ overpaid(PG_FUNCTION_ARGS)
187187
{
188188
TUPLEtuple= (TUPLE)PG_GETARG_POINTER(0);
189189
boolisnull;
190-
longsalary;
190+
int32salary;
191191

192-
salary=(long)GetAttributeByName(tuple,"salary",&isnull);
192+
salary=DatumGetInt32(GetAttributeByName(tuple,"salary",&isnull));
193193
if (isnull)
194194
PG_RETURN_NULL();
195195
PG_RETURN_BOOL(salary>699);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp