AW: [HACKERS] Re: Regress tests reveal *serious* psql bug
AW: [HACKERS] Re: Regress tests reveal *serious* psql bug
От:
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>
Дата:
> SELECT arrtest.a[1:3], > arrtest.b[1:1][1:2][1:2], > arrtest.c[1:2], > arrtest.d[1:1][1:2] > FROM arrtest; Sorry for the stupid question, but can sombody enlighten me. Why was the ":" used in the first place ? I would expect to use a ',' for an array slice. No ? As in: select arrtest.a[1,1][1,2] (This is also what others use for array slices) Andreas
Re: AW: [HACKERS] Re: Regress tests reveal *serious* psql bug
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Zeugswetter Andreas SB writes: > Why was the ":" used in the first place ? I would expect to use a ',' > for an array slice. No ? I'd think a comma is a separator between subscripts for different dimensions, ie, a[1,2] would be equivalent to a[1][2]. It'd certainly surprise *me* if it were interpreted as a slice indicator. In any case, we're stuck with the notation now, I fear. regards, tom lane
Re: AW: [HACKERS] Re: Regress tests reveal *serious* psql bug
От:
Adriaan Joubert <a.joubert@albourne.com>
Дата:
Zeugswetter Andreas SB wrote: > > SELECT arrtest.a[1:3], > > arrtest.b[1:1][1:2][1:2], > > arrtest.c[1:2], > > arrtest.d[1:1][1:2] > > FROM arrtest; > > Sorry for the stupid question, but can sombody enlighten me. > Why was the ":" used in the first place ? I would expect to use a ',' > for an array slice. No ? > > As in: select arrtest.a[1,1][1,2] > (This is also what others use for array slices) In Fortran 90 (one of the few languages that has true arrays with a size as well as a shape) arrays are indexed as A(1:8:2, -2:10) which would mean the 2D array defined by rows (1,3,5,7) and columns (-2,...,10). So ',' is commonly used to separate dimensions, and it would be confusing to suddenly use commas to define a range. And as Fortran is pretty much the grand-daddy of all programming languages we can't really go and change that ;-) Putting indexes in separate ['s is just a modern C'ism, because C has no real multi-dimensional arrays, only pointer dereferencing. Adriaan (a Fortran programmer)