Verifying embedded oids in *recv is a bad idea
От | Andres Freund |
---|---|
Тема | Verifying embedded oids in *recv is a bad idea |
Дата | |
Msg-id | 20160426001713.hbqdiwvf4mkzkg55@alap3.anarazel.de обсуждение исходный текст |
Ответы |
Re: Verifying embedded oids in *recv is a bad idea
|
Список | pgsql-hackers |
Hi, for performance reasons it's a good idea to use the binary protocol. But doing so between two postgres installations is made unnecessarily hard by the choice of embedding and verifying oids in composite and array types. When using extensions, even commonly used ones like hstore, the datatype oids will often not be the same between systems, even when using exactly the same version on the same OS. Specifically I'm talking about Datum array_recv(PG_FUNCTION_ARGS) { ...element_type = pq_getmsgint(buf, sizeof(Oid));if (element_type != spec_element_type){ /* XXX Can we allow taking theinput element type in any cases? */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("wrongelement type")));} ... } and Datum record_recv(PG_FUNCTION_ARGS) { .../* Process each column */for (i = 0; i < ncolumns; i++) ... /* Verify column datatype */ coltypoid = pq_getmsgint(buf, sizeof(Oid)); if (coltypoid != column_type) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("wrong data type: %u, expected%u", coltypoid, column_type))); ... } given that we're giving up quite some speed and adding complexity to make send/recv functions portable, this seems like a shame. I'm failing to see what these checks are buying us? I mean the text representation of a composite doesn't include type information about contained columns either, I don't see why the binary version has to? I'm basically thinking that we should remove the checks on the receiving side, but leave the sending of oids in place for backward compat. Greetings, Andres Freund
В списке pgsql-hackers по дате отправления: