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

Commit32664b4

Browse files
committed
Improve commentary about ArrayRef and ResTarget nodes.
1 parent3406901 commit32664b4

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

‎src/include/nodes/parsenodes.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: parsenodes.h,v 1.76 1999/07/15 23:03:54 momjian Exp $
9+
* $Id: parsenodes.h,v 1.77 1999/07/1803:45:01 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -810,14 +810,23 @@ typedef struct A_Indices
810810
/*
811811
* ResTarget -
812812
* result target (used in target list of pre-transformed Parse trees)
813+
*
814+
* In a SELECT or INSERT target list, 'name' is either NULL or
815+
* the column name assigned to the value. (If there is an 'AS ColumnLabel'
816+
* clause, the grammar sets 'name' from it; otherwise 'name' is initially NULL
817+
* and is filled in during the parse analysis phase.)
818+
* The 'indirection' field is not used at all.
819+
*
820+
* In an UPDATE target list, 'name' is the name of the destination column,
821+
* and 'indirection' stores any subscripts attached to the destination.
822+
* That is, our representation is UPDATE table SET name [indirection] = val.
813823
*/
814824
typedefstructResTarget
815825
{
816826
NodeTagtype;
817-
char*name;/* name of the result column */
818-
List*indirection;/* array references */
819-
Node*val;/* the value of the result (A_Expr or
820-
* Attr) (or A_Const) */
827+
char*name;/* column name or NULL */
828+
List*indirection;/* subscripts for destination column, or NIL */
829+
Node*val;/* the value expression to compute or assign */
821830
}ResTarget;
822831

823832
/*

‎src/include/nodes/primnodes.h

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: primnodes.h,v 1.31 1999/07/16 17:07:33 momjian Exp $
9+
* $Id: primnodes.h,v 1.32 1999/07/18 03:45:01 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -302,13 +302,13 @@ typedef struct SubLink
302302

303303
/* ----------------
304304
* Array
305-
*arrayelemtype-basetype of the array's elements (homogenous!)
305+
*arrayelemtype- type of the array's elements (homogenous!)
306306
*arrayelemlength - length of that type
307-
*arrayelembyval-can you pass thiselementbyvalue?
307+
*arrayelembyval-is theelementtype pass-by-value?
308308
*arrayndim- number of dimensions of the array
309309
*arraylow- base for array indexing
310310
*arrayhigh- limit for array indexing
311-
*arraylen-
311+
*arraylen- total length of array object
312312
* ----------------
313313
*
314314
*memo from mao:the array support we inherited from 3.1 is just
@@ -328,15 +328,39 @@ typedef struct Array
328328
}Array;
329329

330330
/* ----------------
331-
*ArrayRef:
332-
*refelemtype- type of the element referenced here
333-
*refelemlength- length of that type
334-
*refelembyval- can you pass this element type by value?
335-
*refupperindexpr - expressions that evaluate to upper array index
336-
*reflowerexpr- the expressions that evaluate to a lower array index
337-
*refexpr- the expression that evaluates to an array
338-
*refassignexpr- the expression that evaluates to the new value
339-
*to be assigned to the array in case of replace.
331+
*ArrayRef: describes an array subscripting operation
332+
*
333+
* An ArrayRef can describe fetching a single element from an array,
334+
* fetching a subarray (array slice), storing a single element into
335+
* an array, or storing a slice. The "store" cases work with an
336+
* initial array value and a source value that is inserted into the
337+
* appropriate part of the array.
338+
*
339+
*refattrlength- total length of array object
340+
*refelemtype- type of the result of the subscript operation
341+
*refelemlength- length of the array element type
342+
*refelembyval- is the element type pass-by-value?
343+
*refupperindexpr - expressions that evaluate to upper array indexes
344+
*reflowerindexpr- expressions that evaluate to lower array indexes
345+
*refexpr- the expression that evaluates to an array value
346+
*refassgnexpr- expression for the source value, or NULL if fetch
347+
*
348+
* If reflowerindexpr = NIL, then we are fetching or storing a single array
349+
* element at the subscripts given by refupperindexpr. Otherwise we are
350+
* fetching or storing an array slice, that is a rectangular subarray
351+
* with lower and upper bounds given by the index expressions.
352+
* reflowerindexpr must be the same length as refupperindexpr when it
353+
* is not NIL.
354+
*
355+
* Note: array types can be fixed-length (refattrlength > 0), but only
356+
* when the element type is itself fixed-length. Otherwise they are
357+
* varlena structures and have refattrlength = -1. In any case,
358+
* an array type is never pass-by-value.
359+
*
360+
* Note: currently, refelemtype is NOT the element type, but the array type,
361+
* when doing subarray fetch or either type of store. It would be cleaner
362+
* to add more fields so we can distinguish the array element type from the
363+
* result type of the subscript operator...
340364
* ----------------
341365
*/
342366
typedefstructArrayRef

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp