psqlodbc

Started by Thomas G. Lockhartover 27 years ago4 messages
#1Thomas G. Lockhart
lockhart@alumni.caltech.edu

I'm trying to build the ODBC driver to use with an iODBC interface for
the upcoming release of ApplixWare on Linux. I notice that in the last
few days the psqlodbc distribution has acquired a Makefile and a
README.Linux, but the build is not going very well.

Has anyone tried to build on a Unix box recently? If so, how?? The first
file fails on a WINAPI-ed typedef...

- Tom

golem$ make
gcc -g -c -Wall -O -fPIC -I. -I.. -I -I -g -DHAVE_CONFIG_H -c
info.c -o info.o
In file included from info.c:41:
connection.h:166: parse error before `*'
connection.h:177: parse error before `*'
connection.h:202: parse error before `HINSTANCE'
connection.h:202: warning: no semicolon at end of struct or union
connection.h:203: warning: data definition has no type or storage class
connection.h:204: parse error before `DriverToDataSource'
connection.h:204: warning: data definition has no type or storage class
connection.h:207: parse error before `}'
info.c: In function `SQLGetInfo':
info.c:190: dereferencing pointer to incomplete type
info.c:197: dereferencing pointer to incomplete type
info.c:302: dereferencing pointer to incomplete type
info.c:303: dereferencing pointer to incomplete type
info.c:622: dereferencing pointer to incomplete type
info.c:717: dereferencing pointer to incomplete type
info.c:724: dereferencing pointer to incomplete type
info.c:725: dereferencing pointer to incomplete type
info.c:62: warning: `p' might be used uninitialized in this function
info.c: In function `SQLGetTypeInfo':
info.c:746: warning: left-hand operand of comma expression has no effect
info.c:746: warning: statement with no effect
info.c: In function `SQLTables':
info.c:1007: warning: left-hand operand of comma expression has no
effect
info.c:1007: warning: statement with no effect
info.c:1017: dereferencing pointer to incomplete type
info.c:1180: warning: left-hand operand of comma expression has no
effect
info.c:1180: warning: left-hand operand of comma expression has no
effect
info.c:1180: warning: left-hand operand of comma expression has no
effect
info.c:1180: warning: statement with no effect

In reply to: Thomas G. Lockhart (#1)
Re: [INTERFACES] psqlodbc

"Thomas G. Lockhart" <lockhart@alumni.caltech.edu> writes:

I'm trying to build the ODBC driver to use with an iODBC interface for
the upcoming release of ApplixWare on Linux. I notice that in the last
few days the psqlodbc distribution has acquired a Makefile and a
README.Linux, but the build is not going very well.

Has anyone tried to build on a Unix box recently? If so, how?? The first
file fails on a WINAPI-ed typedef...

Try with this patch. Since I doubt anyone needs translation DLLs under
linux I simply ifdefed out some code. Though it's posible to use
dlopen/dlsym/dlclose instead of LoadLibrary/GetProcAddress/FreeLibrary...

Aleksey

diff -c psqlodbc.old/connection.c psqlodbc/connection.c
*** psqlodbc.old/connection.c	Tue Jul 28 13:03:23 1998
--- psqlodbc/connection.c	Tue Jul 28 12:57:17 1998
***************
*** 380,390 ****
--- 380,392 ----
  		}
  	}

+ #ifndef UNIX
/* Check for translation dll */
if ( self->translation_handle) {
FreeLibrary (self->translation_handle);
self->translation_handle = NULL;
}
+ #endif

  	mylog("exit CC_Cleanup\n");
  	return TRUE;
***************
*** 393,399 ****
  int
  CC_set_translation (ConnectionClass *self)
  {
! 
  	if (self->translation_handle != NULL) {
  		FreeLibrary (self->translation_handle);
  		self->translation_handle = NULL;
--- 395,401 ----
  int
  CC_set_translation (ConnectionClass *self)
  {
! #ifndef UNIX
  	if (self->translation_handle != NULL) {
  		FreeLibrary (self->translation_handle);
  		self->translation_handle = NULL;
***************
*** 424,429 ****
--- 426,432 ----
  		self->errormsg = "Could not find translation DLL functions.";
  		return FALSE;
  	}
+ #endif
  	return TRUE;
  }
diff -c psqlodbc.old/connection.h psqlodbc/connection.h
*** psqlodbc.old/connection.h	Tue Jul 28 13:03:10 1998
--- psqlodbc/connection.h	Tue Jul 28 12:36:56 1998
***************
*** 162,167 ****
--- 162,174 ----
  	char			name[MAX_TABLE_LEN+1];
  };
+ #ifdef UNIX
+ #define WINAPI CALLBACK
+ #define DLLHANDLE void *
+ #else
+ #define DLLHANDLE HINSTANCE
+ #endif
+ 
   /* Translation DLL entry points */
  typedef BOOL (FAR WINAPI *DataSourceToDriverProc) (UDWORD,
  					SWORD,
***************
*** 199,205 ****
  	int				ntables;
  	COL_INFO		**col_info;
  	long            translation_option;
! 	HINSTANCE       translation_handle;
  	DataSourceToDriverProc  DataSourceToDriver;
  	DriverToDataSourceProc  DriverToDataSource;
  	char			transact_status;		/* Is a transaction is currently in progress */
--- 206,212 ----
  	int				ntables;
  	COL_INFO		**col_info;
  	long            translation_option;
! 	DLLHANDLE       translation_handle;
  	DataSourceToDriverProc  DataSourceToDriver;
  	DriverToDataSourceProc  DriverToDataSource;
  	char			transact_status;		/* Is a transaction is currently in progress */

--
Aleksey Demakov
avd@gcom.ru

#3Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Thomas G. Lockhart (#1)
Re: [INTERFACES] psqlodbc

I'm trying to build the ODBC driver to use with an iODBC interface
for the upcoming release of ApplixWare on Linux.

Try with this patch.

OK, that seems to help (though there is still major ugliness with the
macro which disables mylog()).

Anyway, I now have a sharable library, and ApplixWare is running. But I
don't see any candidate servers when I try to select a database to open.
I made a ~/.odbc.ini file, and included entries like:

[Postgres]
Debug = 0
CommLog = 1
Driver = /opt/postgres/current/lib/libpsqlodbc.so

but see nothing in the ApplixWare dialog box. Does anyone have a working
.odbc.ini file, perhaps for MySQL? I guess I expected to see "Postgres"
as a candidate database in the ApplixWare dialog box, even if the rest
of the configuration was screwed up. What else needs to be set up??

TIA

- Tom

#4Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Thomas G. Lockhart (#1)
Re: [INTERFACES] psqlodbc

Anyway, I now have a sharable library, and ApplixWare is running.
But I don't see any candidate servers...
I made a ~/.odbc.ini file...

you need one other entry which corresponds to the Postgres entry...
You'll then see a "Postgres Database" entry in the appropriate Data
dialog box.

OK, I followed this suggestion from the Applix folks and it helped. Here
is the file which does better:

<start .odbc.ini file>
[ODBC Data Sources]
Postgres = Postgres Data

[Postgres]
Debug = 0
CommLog = 1
Driver = /opt/postgres/current/lib/libpsqlodbc.so

<eof>

An now Applix can see some candidates. I then got an error from Applix
regarding a missing library:

/opt/applix/axdata/elfodbc: can't load library 'libodbc.so'

which was apparently in the wrong directory in the Applix distribution.
So, I made a soft link to the normal directory area, and now Applix got
further, asking me for a username and password. However, I got the
following error after that:

/opt/applix/axdata/elfodbc: can't resolve symbol 'parse_statement'

When I run "nm" on /opt/postgres/current/lib/libpsqlodbc.so.0.24 I see
the following entry:

mythos> nm libpsqlodbc.so.0.24 | grep -i parse_statement
U parse_statement

which indicates an unresolved symbol. So, I found that parse.c was not
being compiled by Makefile.unx (and my derivative) so got that compiled
and linked and things are much closer to working! :)

OK, so now I get an error message saying:

missing a username, port, or server name

if I use an entry in .odbc.ini which only specifies the driver library
(as above), and I get a similar error message when I specify an
.odbc.ini entry which looks like:

[PostgresFull]
DSN = test
Server = localhost
UID = tgl
Port = 5432
Driver = /opt/postgres/current/lib/libpsqlodbc.so

If I explicitly type the server name (as "localhost") in the Applix
dialog box, I get a different error message:

axnet: Cannot launch gateway on server
not a tcp service in /etc/services

So, anyone have any other hints? What information must be in a real
.odbc.ini file for MySQL to work? I don't have much security turned on
in Postgres, but do have the TCP/IP option specified on the server.

Tried adding an entry in /etc/services, but that alone didn't change the
error message. Anyone have more hints?? :)

- Tom

Oh, btw I have started fixing up a makefile which actually fits into the
Postgres distribution...