vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Tom Lane wrote: > > Andrew's idea of using the enum ordinal value would meet that test, but > at least with the current layout of pg_enum it would be quite expensive > to do the conversion in either direction --- you'd have to fetch > multiple catalog rows. I think we'd have to add another column showing > the ordinal value, and put an index on it, to make I/O reasonably fast. > Doesn't really seem worth it. > > > Yeah. I think we should treat enums just as we do text, for this purpose. Here's a patch (minus catalog bump) which I think does that. cheers andrew ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| Andrew Dunstan <andrew@dunslane.net> writes: > Here's a patch (minus catalog bump) which I think does that. Looks sane in a very quick once-over, but I didn't test it. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |
| |||
| On 8/31/07, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Andrew Dunstan <andrew@dunslane.net> writes: > > Here's a patch (minus catalog bump) which I think does that. > > Looks sane in a very quick once-over, but I didn't test it. works fine (here was my test). thanks for quick resolution to this issue. strings returned in binary format is IMO ok. enum.c: include "libpq-fe.h" #include "string.h" #include <stdlib.h> int main(int argc, char **argv) { PGconn *c = PQconnectdb("user=postgres"); PGresult *r; r = PQexecParams(c, "select 'foo'::foo", 0, NULL, NULL, NULL, NULL, 1); ExecStatusType t = PQresultStatus(r); if(t != PGRES_COMMAND_OK & t != PGRES_TUPLES_OK) { printf("%s", PQresultErrorMessage(r)); exit(1); } char* f = PQgetvalue(r,0,0); int len = 3; int format = 1; PQclear(r); r = PQexecParams(c, "select $1::foo", 1, NULL, (const char* const *)&f, &len, &format, 1); if(t != PGRES_COMMAND_OK & t != PGRES_TUPLES_OK) { printf("%s", PQresultErrorMessage(r)); exit(1); } PQfinish(c); } ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |
| |||
| On 8/31/07, Merlin Moncure <mmoncure@gmail.com> wrote: > On 8/31/07, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Andrew Dunstan <andrew@dunslane.net> writes: > > > Here's a patch (minus catalog bump) which I think does that. > > > > Looks sane in a very quick once-over, but I didn't test it. > > works fine (here was my test). thanks for quick resolution to this > issue. strings returned in binary format is IMO ok. > if(t != PGRES_COMMAND_OK & t != PGRES_TUPLES_OK) oops, this line was wrong. the enum is fine though. merlin ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| ||||
| Merlin Moncure wrote: > On 8/31/07, Tom Lane <tgl@sss.pgh.pa.us> wrote: > >> Andrew Dunstan <andrew@dunslane.net> writes: >> >>> Here's a patch (minus catalog bump) which I think does that. >>> >> Looks sane in a very quick once-over, but I didn't test it. >> > > works fine (here was my test). thanks for quick resolution to this > issue. strings returned in binary format is IMO ok. > > > Patch applied (with catalog bump). cheers andrew ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |