Re: [sqlite] Feat Req Get Aliased Table Name.

2019-01-24 Thread J Decker
https://github.com/mackyle/sqlite/compare/master...d3x0r:TableAliasColumnInfo#diff-ba6bba0411f943cb54c02ee6f03e9a72R1666

Someone at smoe point mentioned "I know know... that's like grabbing memory
from some place untraced right and "

All the other META INFO comes from the same thing.

pTab = pTabList->a[j].pTab;

zOrigCol = pTab->aCol[iCol].zName;
zOrigTab = pTab->zName;

(added; and in the same routine)
zOrigTabAlias =
pTabList->a[j].zAlias ? pTabList->a[j].zAlias : pTabList->a[j].zName;


https://github.com/d3x0r/sqlite/blob/TableAliasColumnInfo/src/select.c#L1723

So basically all that meta info is tied to the lifetime of the preparated
query... and if any of what was already implemented are valid, the new one
is valid, and if they are invalid, the new is similarly invalid; but it'll
never be a case that part of that works and the other doesn't.

Can of course generate a patch; but the first link is the patch, visually
highlighted.
It's not a lot to hand implement, it's really just saving that info

Most of the changes are behind SQLITE_ENABLE_COLUMN_METADATA which controls
the other metadata functions in the group.
That group of functions has an array of entries indexed by

https://github.com/mackyle/sqlite/compare/master...d3x0r:TableAliasColumnInfo?expand=1#diff-6f14e51175412ede90bf483cfca13d6dR143
#define COLNAME_NAME 0
#define COLNAME_DECLTYPE 1 #define COLNAME_DECLTYPE 1
#define COLNAME_DATABASE 2 #define COLNAME_DATABASE 2
#define COLNAME_TABLE 3 #define COLNAME_TABLE 3
#define COLNAME_COLUMN 4 #define COLNAME_COLUMN 4
#define COLNAME_TABLE_ALIAS 5
#ifdef SQLITE_ENABLE_COLUMN_METADATA #ifdef SQLITE_ENABLE_COLUMN_METADATA
# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ # define COLNAME_N
6 /* Number of COLNAME_xxx symbols */

Which "COLANME_N define automatically extends the array to have the
appropriate number of entires, then there's a couple generic accessors to
store/get from that using the other defined values.

On Sun, Mar 18, 2018 at 9:07 PM J Decker  wrote:

> https://sqlite.org/c3ref/column_database_name.html
>
> Source Of Data In A Query Result
> The names returned are the original un-aliased names of the database,
> table, and column.
>
>
> Okay.  and there's...
>
> https://sqlite.org/c3ref/column_name.html
>
> These routines return the name assigned to a particular column in the
> result set of a SELECT  statement.
>
> Which is aliased column names (if aliased)
>
> But there's no way to get the source table aliased.  And I don't think
> database ever gets a chance to be aliased?
>
> 
> SELECT a, sum(b), max(c) FROM t1 m GROUP BY a
>
> There's no C API to get 'm' from the above.
>
> Updated my patch to add the above through
>
>
> +const char *sqlite3_column_table_alias_name(sqlite3_stmt*,int);
> +const void *sqlite3_column_table_alias_name16(sqlite3_stmt*,int);
>
> which is added with the top mentionend function groups behind
> SQLITE_ENABLE_COLUMN_METADATA
>
> table_alias_info.fossil.patch
> https://drive.google.com/open?id=1c24qvtvS57ASJF5RfZxLJSsgI2FhOVk1
>
> Visual diff.
> https://github.com/d3x0r/sqlite3/compare/AddTableAliasForColumn?expand=1
>
>
> It's not very large.  It just has to allocate one more element in the
> array of column info allocated by METADATA flag and set it when it sets
> the rest, and expose it with an API call.
>
>
> Even if it's just taken as inspiration, please add something to expose the
> alias.
>
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Feat Req Get Aliased Table Name.

2018-03-18 Thread J Decker
https://sqlite.org/c3ref/column_database_name.html

Source Of Data In A Query Result
The names returned are the original un-aliased names of the database,
table, and column.


Okay.  and there's...

https://sqlite.org/c3ref/column_name.html

These routines return the name assigned to a particular column in the
result set of a SELECT  statement.

Which is aliased column names (if aliased)

But there's no way to get the source table aliased.  And I don't think
database ever gets a chance to be aliased?


SELECT a, sum(b), max(c) FROM t1 m GROUP BY a

There's no C API to get 'm' from the above.

Updated my patch to add the above through


+const char *sqlite3_column_table_alias_name(sqlite3_stmt*,int);
+const void *sqlite3_column_table_alias_name16(sqlite3_stmt*,int);

which is added with the top mentionend function groups behind
SQLITE_ENABLE_COLUMN_METADATA

table_alias_info.fossil.patch
https://drive.google.com/open?id=1c24qvtvS57ASJF5RfZxLJSsgI2FhOVk1

Visual diff.
https://github.com/d3x0r/sqlite3/compare/AddTableAliasForColumn?expand=1


It's not very large.  It just has to allocate one more element in the array
of column info allocated by METADATA flag and set it when it sets the
rest, and expose it with an API call.


Even if it's just taken as inspiration, please add something to expose the
alias.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users