src/backend/parser/parse_expr.c:exprTypmod() question
От | Teodor Sigaev |
---|---|
Тема | src/backend/parser/parse_expr.c:exprTypmod() question |
Дата | |
Msg-id | 45227620.4090306@sigaev.ru обсуждение исходный текст |
Ответы |
Re: src/backend/parser/parse_expr.c:exprTypmod() question
|
Список | pgsql-hackers |
I'm working on user-defined typmod and try to move all typmod calculations into type-specific functions. But there is a strange place: /* * exprTypmod - * returns the type-specific attrmod of the expression, if it can be * determined. In most cases,it can't and we return -1. */ int32 exprTypmod(Node *expr) { <skip> case T_Const: { /* Be smart about string constants... */ Const *con = (Const *) expr; switch (con->consttype) { case BPCHAROID: if (!con->constisnull) { int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ; /* if multi-byte, take len and find # characters */ if (pg_database_encoding_max_length()> 1) len = pg_mbstrlen_with_len(VARDATA(DatumGetPointer(con->constvalue)), len); return len + VARHDRSZ; } break; default: break; } } break; So, I can't understand why it's needed at all. First, it's returns length as typmod, second, it looks like optimization, but I don't believe in significant benefits... It's a constant coming from query. Am I missing something? -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/
В списке pgsql-hackers по дате отправления: