Re: AW: [HACKERS] Re: Regress tests reveal *serious* psql bug
От | Adriaan Joubert |
---|---|
Тема | Re: AW: [HACKERS] Re: Regress tests reveal *serious* psql bug |
Дата | |
Msg-id | 387E0077.2F6D206C@albourne.com обсуждение исходный текст |
Ответ на | AW: [HACKERS] Re: Regress tests reveal *serious* psql bug (Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>) |
Список | pgsql-hackers |
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)
В списке pgsql-hackers по дате отправления: