vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello everyone - Array columns are, by default, 1-offset in their subscripting. Since I usually call postgres from a language with zero-offset, I would prefer that postgres conform to that. The online documentation hints that this may be configurable but I haven't been able to find how this is done. Does anyone know how to do this? Thanks, Erin Sheldon ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| ||||
| Erin Sheldon wrote: > Hello everyone - > > Array columns are, by default, 1-offset in their > subscripting. Since I usually call postgres > from a language with zero-offset, I would prefer > that postgres conform to that. The online > documentation hints that this may be configurable > but I haven't been able to find how this is done. Actuall, postgresql arrays can "start" (and "end", of course) at arbitrary offsets. You could, e.g., have an array that his elements for subscripts from -5 to 5. Thats why the functions array_upper and array_lower exist - otherwise, it would be sufficient to have array_length. But you're right that postgres "defaults" to offset 1 in the sense that all predefined functions that generate arrays return arrays with offset 1. I'm not aware of a way to change that, but you could replace or wrap those functions with versions that return "offset 0" arrays. I'm not sure if it's worth the effort, though, since you're app (or it's db abstraction layer) will need to converts arrays between a "native" representations and a "sql" representation anyway. You could just do the mapping there.. greetings, Florian Pflug ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |