RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES macros.in

From: Mark Hatle <mark.hatle@windriver.com>
Date: Thu 28 Jun 2007 - 23:29:44 CEST
Message-ID: <46842848.6020602@windriver.com>
Is "TEMPORARY TABLE" something special?  I knew about the :memory:
before, but not the other.

Otherwise this looks good to me.  It may even speed things up slightly.

--Mark

Ralf S. Engelschall wrote:
> On Thu, Jun 28, 2007, Mark Hatle wrote:
> 
>> Ahh you just reminded me of a bug.  I'm not sure how to fix this using
>> the dynamic values..  But basically, "Depends" can't be in the _dbi_tags
>> if you are using sqlite.  If you notice in the fragment below, on db3
>> it's setup as a "temporary private" database used for single-run
>> optimization.  On the sqlite side, it becomes a "permanent" cache..  The
>> problem with that is that it only holds partial dependency data.. so you
>> suddenly start to get failures.
>> [...]
> 
> How about the particular (still fully untested) change appended below?
> 
> It enables "private" and "temporary" for SQLite and implements
> "temporary" via SQLite's special ":memory:" database and "private" via
> "CREATE TEMPORARY TABLE".
> 
> Feedback?
>                                        Ralf S. Engelschall
>                                        rse@engelschall.com
>                                        www.engelschall.com
> Index: macros.in
> ===================================================================
> RCS file: /v/rpm/cvs/rpm/macros.in,v
> retrieving revision 1.167
> diff -u -d -u -d -r1.167 macros.in
> --- macros.in	28 Jun 2007 16:41:51 -0000	1.167
> +++ macros.in	28 Jun 2007 21:15:38 -0000
> @@ -648,7 +648,7 @@
>  # database tag configuration
>  %_dbi_tags                      %{expand:%%{_dbi_tags_%{_dbapi_used}}}
>  %_dbi_tags_3                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Pubkeys:Packagecolor:Depends
> -%_dbi_tags_4                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Pubkeys:Packagecolor
> +%_dbi_tags_4                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Pubkeys:Packagecolor:Depends
> 
>  # database configuration: Berkeley-DB [dbapi 3 hooks]
>  %_dbi_config_3                  %{_dbi_btconfig}
> @@ -692,7 +692,7 @@
>  %_dbi_config_4_Sigmd5           %{_dbi_sqlconfig}
>  %_dbi_config_4_Triggername      %{_dbi_sqlconfig}
>  %_dbi_config_4_Packages         %{_dbi_sqlconfig}
> -%_dbi_config_4_Depends          %{_dbi_sqlconfig}
> +%_dbi_config_4_Depends          %{_dbi_sqlconfig} temporary private
> 
>  # database configuration [code entry hooks]
>  %_dbi_config                    %{expand:%%{_dbi_config_%{_dbapi_used}}}
> Index: rpmdb/dbconfig.c
> ===================================================================
> RCS file: /v/rpm/cvs/rpm/rpmdb/dbconfig.c,v
> retrieving revision 1.39
> diff -u -d -u -d -r1.39 dbconfig.c
> --- rpmdb/dbconfig.c	28 Jun 2007 15:52:05 -0000	1.39
> +++ rpmdb/dbconfig.c	28 Jun 2007 21:15:39 -0000
> @@ -112,7 +112,7 @@
>   { "lockdown",	0,POPT_BIT_SET,	&db3dbi.dbi_eflags, DB_LOCKDOWN,
>  	NULL, NULL },
>  #endif
> -#if defined(WITH_DB) && defined(DB_PRIVATE)
> +#if (defined(WITH_DB) || defined(WITH_SQLITE)) && defined(DB_PRIVATE)
>   { "private",	0,POPT_BIT_SET,	&db3dbi.dbi_eflags, DB_PRIVATE,
>  	NULL, NULL },
>  #endif
> @@ -288,8 +288,10 @@
>  	NULL, NULL },
>   { "lockdbfd",	0,POPT_ARG_NONE,	&db3dbi.dbi_lockdbfd, 0,
>  	NULL, NULL },
> +#endif
>   { "temporary",	0,POPT_ARG_NONE,	&db3dbi.dbi_temporary, 0,
>  	NULL, NULL },
> +#if defined(WITH_DB)
>   { "debug",	0,POPT_ARG_NONE,	&db3dbi.dbi_debug, 0,
>  	NULL, NULL },
>  #endif
> Index: rpmdb/rpmdb.h
> ===================================================================
> RCS file: /v/rpm/cvs/rpm/rpmdb/rpmdb.h,v
> retrieving revision 1.59
> diff -u -d -u -d -r1.59 rpmdb.h
> --- rpmdb/rpmdb.h	28 Jun 2007 15:52:05 -0000	1.59
> +++ rpmdb/rpmdb.h	28 Jun 2007 21:15:39 -0000
> @@ -15,6 +15,9 @@
>  #else
>  #include "db_emu.h"
>  #endif
> +#if defined(WITH_SQLITE) && !defined(DB_PRIVATE)
> +#define DB_PRIVATE 0x0200000 /* shameless hack for shared option */
> +#endif
> 
>  /*@-exportlocal@*/
>  /*@unchecked@*/
> Index: rpmdb/sqlite.c
> ===================================================================
> RCS file: /v/rpm/cvs/rpm/rpmdb/sqlite.c,v
> retrieving revision 1.6
> diff -u -d -u -d -r1.6 sqlite.c
> --- rpmdb/sqlite.c	19 Jun 2007 09:34:45 -0000	1.6
> +++ rpmdb/sqlite.c	28 Jun 2007 21:15:39 -0000
> @@ -729,13 +729,15 @@
>  	}
>  if (_debug)
>  fprintf(stderr, "\t%s(%d) type(%d) keytype %s\n", tagName(dbi->dbi_rpmtag), dbi->dbi_rpmtag, (tagType(dbi->dbi_rpmtag) & RPM_MASK_TYPE), keytype);
> -	sprintf(cmd, "CREATE TABLE '%s' (key %s, value %s)",
> +	sprintf(cmd, "CREATE %sTABLE '%s' (key %s, value %s)",
> +			dbi->dbi_eflags & DB_PRIVATE ? "TEMPORARY " : "",
>  			dbi->dbi_subfile, keytype, valtype);
>  	rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
>  	if (rc)
>  	    goto exit;
> 
> -	sprintf(cmd, "CREATE TABLE 'db_info' (endian TEXT)");
> +	sprintf(cmd, "CREATE %sTABLE 'db_info' (endian TEXT)",
> +			dbi->dbi_eflags & DB_PRIVATE ? "TEMPORARY " : "");
>  	rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
>  	if (rc)
>  	    goto exit;
> @@ -922,7 +924,10 @@
>       */
>      (void) rpmioMkpath(dbhome, 0755, getuid(), getgid());
> 
> -    dbfname = rpmGenPath(dbhome, dbi->dbi_file, NULL);
> +    if (dbi->dbi_temporary)
> +        dbfname = strdup(":memory:");
> +    else
> +        dbfname = rpmGenPath(dbhome, dbi->dbi_file, NULL);
> 
>      rpmMessage(RPMMESS_DEBUG, _("opening  sql db         %s (%s) mode=0x%x\n"),
>  		dbfname, dbi->dbi_subfile, dbi->dbi_mode);
> 
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> Developer Communication List                        rpm-devel@rpm5.org
Received on Thu Jun 28 23:29:50 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.