[Home]

Summary:ASTERISK-23582: [patch]Inconsistent column length in *odbc
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2014-04-03 06:19:56Date Closed:2014-05-28 06:35:34
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Functions/func_odbc Resources/res_config_odbc
Versions:SVN 1.8.26.1 Frequency of
Occurrence
Related
Issues:
is related toASTERISK-08030 macro's appdata can't be longer than 114 chars plus a 3 chars exten
Environment:Attachments:( 0) issueA23582_add_ast_realtime_data_minlen_global.patch
Description:ODBC uses arbitrary 3 maximum column lengths:
* static realtime var_val holds at most 1023 bytes
* dynamic realtime columns hold at most 2047 bytes
* func_odbc queries can also be at most 2047 bytes

Config reading from plain files (non-static realtime) does not have this 1023 byte limit.

And the other res_config_* do not seem affected by similar arbitrary limits.

Possible fixes:
* Add a global setting that holds a single global value to keep them in sync
* Fix the separate static allocations to be dynamic.

The first fix is attached.

The second fix is relatively easy for {{var_val}} and func_odbc. We could begin the static-realtime-conf reading with a {{SELECT MAX(LENGTH(var_val))}} or we could simply check for failed allocations and enlarge the heap-allocated buffer. That should happen very infrequently anyway. For the dynamic realtime a thread-local buffer would probably be preferred since we don't want to reallocate often there.

Thoughts?

P.S. The attached patch works for static-realtime-loaded func_odbc conf, loading a large select query. For example:
{noformat}
readsql=SELECT 000 UNION SELECT 001 UNION SELECT 002 UNION SELECT 003 UNION SELECT 004 UNION SELECT 005 UNION SELECT 006 UNION SELECT 007 UNION SELECT 008 UNION SELECT 009 UNION
SELECT 010 UNION SELECT 011 UNION SELECT 012 UNION SELECT 013 UNION SELECT 014 UNION SELECT 015 UNION SELECT 016 UNION SELECT 017 UNION SELECT 018 UNION SELECT 019 UNION
SELECT 020 UNION SELECT 021 UNION SELECT 022 UNION SELECT 023 UNION SELECT 024 UNION SELECT 025 UNION SELECT 026 UNION SELECT 027 UNION SELECT 028 UNION SELECT 029 UNION
SELECT 030 UNION SELECT 031 UNION SELECT 032 UNION SELECT 033 UNION SELECT 034 UNION SELECT 035 UNION SELECT 036 UNION SELECT 037 UNION SELECT 038 UNION SELECT 039 UNION
SELECT 040 UNION SELECT 041 UNION SELECT 042 UNION SELECT 043 UNION SELECT 044 UNION SELECT 045 UNION SELECT 046 UNION SELECT 047 UNION SELECT 048 UNION SELECT 049 UNION
SELECT 050 UNION SELECT 051 UNION SELECT 052 UNION SELECT 053 UNION SELECT 054 UNION SELECT 'X' UNION SELECT 056 UNION SELECT 057 UNION SELECT 058 UNION SELECT 059 UNION
SELECT 060 UNION SELECT 061 UNION SELECT 062 UNION SELECT 063 UNION SELECT 064 UNION SELECT 065 UNION SELECT 066 UNION SELECT 067 UNION SELECT 068 UNION SELECT 069 UNION
SELECT 070 UNION SELECT 071 UNION SELECT 072 UNION SELECT 073 UNION SELECT 074 UNION SELECT 075 UNION SELECT 076 UNION SELECT 077 UNION SELECT 078 UNION SELECT 079 UNION
SELECT 080 UNION SELECT 081 UNION SELECT 082 UNION SELECT 083 UNION SELECT 084 UNION SELECT 085 UNION SELECT 086 UNION SELECT 087 UNION SELECT 088 UNION SELECT 089 UNION
SELECT 090 UNION SELECT 091 UNION SELECT 092 UNION SELECT 093 UNION SELECT 094 UNION SELECT 095 UNION SELECT 096 UNION SELECT 097 UNION SELECT 098 UNION SELECT 099 UNION
SELECT 100 UNION SELECT 101 UNION SELECT 102 UNION SELECT 103 UNION SELECT 104 UNION SELECT 105 UNION SELECT 106 UNION SELECT 107 UNION SELECT 108 UNION SELECT 109 UNION
SELECT 110 UNION SELECT 111 UNION SELECT 112 UNION SELECT 113 UNION SELECT 114 UNION SELECT 115 UNION SELECT 116 UNION SELECT 117 UNION SELECT 118 UNION SELECT 119 UNION
SELECT 999 ORDER BY 1 DESC LIMIT 1
{noformat}
Comments:By: Walter Doekes (wdoekes) 2014-04-03 06:35:17.566-0500

And yes, before someone complains that my queries are too long: with a couple of joins and constructs like these \[1] you'll quickly exceed 1023 bytes.

I'm moving over all queries that used to be views to direct queries, because MySQL isn't all that good at optimizing queries on some of those views.

\[1] {{SUBSTRING(f3.`file`, 1, LENGTH(f3.`file`) - LOCATE('.', REVERSE(f3.`file`))) AS `timeout_filename_without_ext`,}}

By: Rusty Newton (rnewton) 2014-04-08 11:21:00.548-0500

You'll want to go ahead and post on Reviewboard and then add the link on here. Thanks Walter!

By: Jonathan Rose (jrose) 2014-05-07 14:04:49.580-0500

*poke*

Are you still working on this patch Walter, or do we just need to review the patch currently on the issue?

By: Walter Doekes (wdoekes) 2014-05-08 09:52:00.288-0500

No, I'm not working on this right now.

I mainly needed to know which limits I would run into and where they are. The proper fix would be to make everything heap allocated, but I don't have time to fix that right now.

If I put this patch up for review, I expect someone to say that, and then the patch would stall anyway.