[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gambas-user
Subject:    Re: [Gambas-user] Gambas & PostgreSQL cannot create index. relation
From:       "Ron_1st" <ronstk () tiscali ! nl>
Date:       2009-01-24 18:32:46
Message-ID: 200901241932.46428.ronstk () tiscali ! nl
[Download RAW message or body]

On Saturday 24 January 2009, Randy wrote:
> Hello Rolf,
> 
> I try to make index on any of the fields. The code that I posted is the 
> last try and not what I intended for indexes for the table.  If I try to 
> make indexes on any of the fields, Gambas fails with that error message. 
> I turn on the DB.Bebug and try to make index for glsort field only.
> 
> 
> Here's the debug output with index:
> 
> postgresql: 0x8159aa8: select substring(version(),12,5)
> postgresql: 0x8159aa8: show client_encoding
> postgresql: 0x8159aa8: select relname from pg_class where (relkind = 'r' 
> or relkind = 'v') and (relname = 'glcoa') and (relnamespace not in 
> (select oid from pg_namespace where nspname = 'information_schema'))
> postgresql: 0x8159aa8: select pg_class.relname from pg_class, pg_index, 
> pg_class pg_class2 where pg_class2.relname = 'glcoa' and 
> (pg_class2.relnamespace not in (select oid from pg_namespace where 
> nspname = 'information_schema')) and pg_index.indrelid = pg_
> class2.oid and pg_index.indexrelid = pg_class.oid and pg_class.relname = 
> 'glcoa_sort'
> postgresql: 0x8159aa8: CREATE UNIQUE INDEX "glcoa_sort" ON glcoa ( glsort )
> 
> 
> Here's the debug output without index:
> 
> postgresql: 0x8159de8: select substring(version(),12,5)
> postgresql: 0x8159de8: show client_encoding
> postgresql: 0x8159de8: select relname from pg_class where (relkind = 'r' 
> or relkind = 'v') and (relname = 'glcoa') and (relnamespace not in 
> (select oid from pg_namespace where nspname = 'information_schema'))
> postgresql: 0x8159de8: CREATE TABLE "glcoa" ( "company" VARCHAR(3), 
> "account" VARCHAR(12) NOT NULL , "description" VARCHAR(32), "gltype" 
> VARCHAR(1), "glsort" INT, "status" VARCHAR(1), PRIMARY KEY (account) )
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 
> "glcoa_pkey" for table "glcoa"
> 
> 
> With indexes Gambas doesn't create the table! Bug?
> 
> 
> Randy :-)
> 

I just take a look in the source code
---------------------
BEGIN_METHOD(CINDEX_add, GB_STRING name; GB_STRING fields; GB_BOOLEAN unique)

  CTABLE *table = GB.SubCollection.Container(THIS);
  char *name = GB.ToZeroString(ARG(name));
  DB_INDEX info;

  if (DB_CheckName(name, "index"))
    return;

  if (check_index(table, name, FALSE))
    return;

  info.name = name;
  info.fields = GB.ToZeroString(ARG(fields));
  info.unique = VARGOPT(unique, FALSE);

  table->driver->Index.Create(&table->conn->db, table->name, name, &info);

END_METHOD


----------------------------
  if (check_index(table, name, FALSE))
    return;

'name' here is your 'glcoa_sort'

My comment here is that it _looks_ as the required name 'glcoa_sort' must 
exist/notexist also as field name in the table.
It should be not exists of course.

In the above source the last line starting with table looks to me
as Create index ('thedatabse', table->'glcoa_sort', 'glcoa_sort' , DB_INDEX)

what results in: "glcoa_sort" ON glcoa (glsort) 
Anyway here happens something strange to me.



Did you Try it with 'glcoaaccount' and 'glcoasort' (without the underscore) ???
and what happens then?

In your reply:
postgresql: 0x8159aa8: CREATE UNIQUE INDEX "glcoa_sort" ON glcoa ( glsort )

it look as it try to use table glcoa, the name after ON !!

BTW do you have a table named glcoa?


@benoit

in CIndex.h

void *CINDEX_get(CTABLE *table, const char *name);
int CINDEX_exist(CTABLE *table, const char *name);
void CINDEX_list(CTABLE *table, char ***list);
void CINDEX_release(CTABLE *table, void *_object);

I missing CINDEX_create ????
Second why the first is void *CIndex and the two last void CIndex ??




Best regards,

Ron_1st

-- 
 A: Delete the text you reply on.
 Q: What to do to get my post on top?
 A: Because it messes up the order in which people normally read text. 
 Q: Why is top-posting such a bad thing? 
 A: Top-posting. 
 Q: What is the most annoying thing in e-mail? 
 

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic