[Gambas-user] Extracting fields from a Result

Doug Hutcheson owlbrudder at gmail.com
Tue Jan 2 07:30:40 CET 2018



On Tue, 2018-01-02 at 15:18 +1000, Doug Hutcheson wrote:
> On Tue, 2018-01-02 at 14:34 +1000, Doug Hutcheson wrote:
> > On Mon, 2018-01-01 at 23:12 -0500, T Lee Davidson wrote:
> > > On 01/01/2018 10:00 PM, Doug Hutcheson wrote:
> > > > I changed the code to connect to my database and the following
> > > > was the output:
> > > > [doug at womble <mailto:doug at womble>
> > > > CommandLinePostgreSQLtestApp]$
> > > > ./CommandLinePostgreSQLtestApp.gambas 
> > > > Connected.
> > > > Main.Main.24: 35
> > > > Main.Main.25: Main.Main.25: Unknown field: txtMasterDatabase
> > > > Main.Main.25 
> > > > 
> > > > 35 is the correct field count; txtMasterDatabase is the first
> > > > field in the table.
> > > > 
> > > > I have attached two source archives: one is my PostgreSQL test
> > > > application - the one which started this thread - and the other
> > > > is your command line application. Please feel free to point out
> > > > if I have done something stupid, because I am at the start of
> > > > my
> > > > Gambas learning curve and welcome any input.
> > > > 
> > > 
> > > Looking at the name of the first field in the table reminded me
> > > of something I stumbled across during my foray into PostgreSQL
> > > land. It has an issue with mixed-case names.
> > > 
> > > https://stackoverflow.com/questions/20878932/are-postgresql-colum
> > > n-names-case-sensitive :
> > > "All identifiers (including column names) that are not double-
> > > quoted are folded to lower case in PostgreSQL."
> > > 
> > > 
> > Darn! I knew about that restriction and commonly double-quote my
> > identifiers for that reason. Sure 'nuff, when I change the first
> > field name to all lower-case the loop works fine, then barfs on the
> > next one which I have not changed.
> > 
> > Looks like you have solved that much of the quandary for me, Lee.
> > Give yourself a gold star and an elephant stamp!   "8-)
> > 
> > Now I will see if it solves the problem of the Connections not
> > wanting to play nicely. I'll get back to you on that.
> > 
> > Cheers, Doug
> 
> Hi Lee. Nope, it does not help with the Connections problem. My
> Connections tool correctly shows all my tables and browses my data,
> but attempting to use a Connection with a Datasource control and
> giving it a tablename visible in the Connections tool, causes the
> error "Cannot open database: fe_sendauth: no password supplied".
> 
> I am a retired C and VBA programmer with more time than sense, so
> I'll poke around in the Gambas source (gb.db, gb.db.mysql,
> gb.db.postgresql for a start) and see what I can see. The field names
> issue might just be a matter of double-quoting each time a field is
> accessed and the password issue seems to be common to MySql and
> PostgreSQL so is going to be something obvious. I'll let you know if
> I find anything interesting.
> Cheers, Doug

Hi Lee.

A first look at the code tells me three things:
1. gb.db.postgresql/main.c contains code to quote identifiers, but I
will have to look further to determine whether it uses a single quote
or a double quote. Suspicious, but needs more investigation. If it uses
a sinle quote, that will be our problem right there.
2. Both gb.db.mysql/main.c and gb.db.postgresql/main.c have a routine
to open a database. In each case, the parameters - including password -
are contained in a structure passed to the routine. I will have to dig
more to determine whether the password is actually being passed. Logic
says it must be, because others would have tripped over this problem in
the past, but the evidence on my machine at least suggests the password
is not being correctly embedded in the structure.
3. I don't seem to have the source for gb.db, which is where I expect
to find some of the high-level code and structures. Will dig more.

Now, before I go any further, I don't want to be treading on anyone's
toes. If it is not my place to go ferreting around in the code please
let me know - the last thing I want is to give anyone offence.

If it is OK, I will gladly dive in and see what I can contribute.

Cheers, Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180102/a4852620/attachment-0001.html>


More information about the User mailing list