From mihai at bazon.net Sat Oct 3 09:23:33 2009 From: mihai at bazon.net (Mihai Bazon) Date: Sat, 3 Oct 2009 12:23:33 +0300 Subject: [Cl-perec-devel] undefined variable: PERSISTENT-OBJECT Message-ID: Hi, Using the following code to select a few instances: (with-transaction (select-instances (o) (where (member (oid-of o) list-of-oids)))) If I specify a type, i.e. (select-instances (o base-type)) then it works (even if the selected instances are of mixed types derived from base-type), but without it I get this warning: ; caught WARNING: ; This variable is undefined: ; PERSISTENT-OBJECT Probably a bug in perec? Cheers, -Mihai From tomi.borbely at gmail.com Mon Oct 5 10:29:44 2009 From: tomi.borbely at gmail.com (=?ISO-8859-1?Q?Borb=E9ly_Tam=E1s_?=) Date: Mon, 5 Oct 2009 12:29:44 +0200 Subject: [Cl-perec-devel] undefined variable: PERSISTENT-OBJECT In-Reply-To: References: Message-ID: <53c1332f0910050329s7b7d9a4bsa6ec695b8dbdeee2@mail.gmail.com> It was a bug, fixed now. Thanks for reporting. Tomi 2009/10/3 Mihai Bazon > Hi, > > Using the following code to select a few instances: > > (with-transaction > (select-instances (o) > (where (member (oid-of o) list-of-oids)))) > > If I specify a type, i.e. (select-instances (o base-type)) then it > works (even if the selected instances are of mixed types derived from > base-type), but without it I get this warning: > > ; caught WARNING: > ; This variable is undefined: > ; PERSISTENT-OBJECT > > Probably a bug in perec? > > Cheers, > -Mihai > _______________________________________________ > Cl-perec-devel mailing list > Cl-perec-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai at bazon.net Fri Oct 9 13:00:35 2009 From: mihai at bazon.net (Mihai Bazon) Date: Fri, 9 Oct 2009 16:00:35 +0300 Subject: [Cl-perec-devel] Optimization question Message-ID: Hi folks, Here are two variants, I'd say equivalent, to select some objects: (select-instances (o) (where (typep o 'db-group))) (defvar tmp 'db-user) (select-instances (o) (where (typep o tmp))) Both work the same, but the first one is better because it results in a single select that fetches the data as well. Here's what I see using start-sql-recording: 1st version: ; SELECT _o._oid, _o._edition, _o._name, _o._description FROM _db_group_ap _o 2nd version: ; SELECT _o._oid FROM _db_group_ai _o ; $1 = 69012 as BIGINT ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) ; $1 = 134548 as BIGINT ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) ; $1 = 200084 as BIGINT ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) I presume there's some compile-time magic that happens in case 1 and not in case 2. I can't hard-code the type so I'd like to use the second variant, but is it possible to optimize it so that it results in a single select like the first one? Thanks for any hints! -Mihai From attila.lendvai at gmail.com Fri Oct 9 13:56:48 2009 From: attila.lendvai at gmail.com (Attila Lendvai) Date: Fri, 9 Oct 2009 15:56:48 +0200 Subject: [Cl-perec-devel] Optimization question In-Reply-To: References: Message-ID: > variant, but is it possible to optimize it so that it results in a > single select like the first one? someone somewhere needs to add a cond that dispatches on the interesting types. perec has not much chance, because it doesn't really know what are the possible/interesting types to dispatch on (and collecting runtime information and dynamically recompiling is beyond the scope of a lib without the environment supporting it) so, i suggest to create a macro for which you can give a list of types and a code body, and builds up the dispatch for you. something similar to sb-imp::string-dispatch: (defmacro string-dispatch ((&rest types) var &body body) (let ((fun (sb!xc:gensym "STRING-DISPATCH-FUN"))) `(flet ((,fun (,var) , at body)) (declare (inline ,fun)) (etypecase ,var ,@(loop for type in types ;; TRULY-THE allows transforms to take advantage of the type ;; information without need for constraint propagation. collect `(,type (,fun (truly-the ,type ,var)))))))) -- attila From levente.meszaros at gmail.com Fri Oct 9 16:47:31 2009 From: levente.meszaros at gmail.com (=?ISO-8859-1?Q?Levente_M=E9sz=E1ros?=) Date: Fri, 9 Oct 2009 18:47:31 +0200 Subject: [Cl-perec-devel] Optimization question In-Reply-To: References: Message-ID: I suggest to build a query form dynamically and execute that. Query cache will prevent calling the query compiler each time and you can build free queries with this. TEST> (defpclass* foo () ((s :type boolean))) # TEST> (with-transaction (make-instance 'foo :s t)) ; BEGIN ; SELECT NEXTVAL('_instance_id') ; $1 = 475775 as BIGINT, $2 = TRUE as BOOL ; INSERT INTO _foo (_oid, _s) VALUES ($1::BIGINT, $2::BOOL) ; COMMIT # TEST> (with-transaction (execute-query (make-query '(select-instances (o) (where (typep o 'foo)))))) ; BEGIN ; SELECT _o._oid, _o._s FROM _foo_ap _o ; COMMIT (# # # #) Be sure to bind this variable high enough: TEST> hu.dwim.perec::*compiled-query-cache* # levy -- There's no perfectoin On Fri, Oct 9, 2009 at 3:00 PM, Mihai Bazon wrote: > Hi folks, > > Here are two variants, I'd say equivalent, to select some objects: > > ? (select-instances (o) (where (typep o 'db-group))) > > ? (defvar tmp 'db-user) > ? (select-instances (o) (where (typep o tmp))) > > Both work the same, but the first one is better because it results in a > single select that fetches the data as well. ?Here's what I see using > start-sql-recording: > > 1st version: > > ; SELECT _o._oid, _o._edition, _o._name, _o._description FROM _db_group_ap _o > > 2nd version: > > ; SELECT _o._oid FROM _db_group_ai _o > ; $1 = 69012 as BIGINT > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > ; $1 = 134548 as BIGINT > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > ; $1 = 200084 as BIGINT > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > > I presume there's some compile-time magic that happens in case 1 and not > in case 2. ?I can't hard-code the type so I'd like to use the second > variant, but is it possible to optimize it so that it results in a > single select like the first one? > > Thanks for any hints! > -Mihai > _______________________________________________ > Cl-perec-devel mailing list > Cl-perec-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > From mihai at bazon.net Fri Oct 9 17:35:18 2009 From: mihai at bazon.net (Mihai Bazon) Date: Fri, 9 Oct 2009 20:35:18 +0300 Subject: [Cl-perec-devel] Optimization question In-Reply-To: References: Message-ID: <6e131de2bdfe1c0dcf3292988b328d23@bazon.net> You hard-coded the type, which is what I want to avoid. That works, but consider the following: (defvar tmp 'foo) ;*** the type is in a variable (with-transaction (execute-query (make-query '(select-instances (o) (where (typep o tmp))))))) It results in: ; BEGIN ; SELECT _o._oid FROM _foo_ai _o ; COMMIT (so it doesn't select all data, only the OID; the result is a list of objects, but individual SELECT-s will run for each of them to retrieve the value of 's when it's needed). BTW: I'm setting compiled-query-cache like this: (let ((prc::*compiled-query-cache* (site-query-cache ,site)) ... where site-query-cache is an accessor for the following slot: (query-cache :accessor site-query-cache :initform (prc::make-compiled-query-cache)) It seems to work, and definitely improves performance (about 2x faster). Hope it's a clean way... Tomorrow I'll try to understand how to use the macro that Attila suggested--again, sorry for I'm trying to learn too much in too little time... Cheers, -Mihai Levente M?sz?ros wrote: > I suggest to build a query form dynamically and execute that. Query > cache will prevent calling the query compiler each time and you can > build free queries with this. > > TEST> (defpclass* foo () > ((s :type boolean))) > # > > TEST> (with-transaction > (make-instance 'foo :s t)) > > ; BEGIN > ; SELECT NEXTVAL('_instance_id') > ; $1 = 475775 as BIGINT, $2 = TRUE as BOOL > ; INSERT INTO _foo (_oid, _s) VALUES ($1::BIGINT, $2::BOOL) > ; COMMIT > # > > TEST> (with-transaction (execute-query (make-query '(select-instances > (o) (where (typep o 'foo)))))) > ; BEGIN > ; SELECT _o._oid, _o._s FROM _foo_ap _o > ; COMMIT > (# # # > #) > > Be sure to bind this variable high enough: > > TEST> hu.dwim.perec::*compiled-query-cache* > # > > levy > > -- > There's no perfectoin > > On Fri, Oct 9, 2009 at 3:00 PM, Mihai Bazon wrote: > > Hi folks, > > > > Here are two variants, I'd say equivalent, to select some objects: > > > > ? (select-instances (o) (where (typep o 'db-group))) > > > > ? (defvar tmp 'db-user) > > ? (select-instances (o) (where (typep o tmp))) > > > > Both work the same, but the first one is better because it results in a > > single select that fetches the data as well. ?Here's what I see using > > start-sql-recording: > > > > 1st version: > > > > ; SELECT _o._oid, _o._edition, _o._name, _o._description FROM _db_group_ap _o > > > > 2nd version: > > > > ; SELECT _o._oid FROM _db_group_ai _o > > ; $1 = 69012 as BIGINT > > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > > ; $1 = 134548 as BIGINT > > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > > ; $1 = 200084 as BIGINT > > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > > > > I presume there's some compile-time magic that happens in case 1 and not > > in case 2. ?I can't hard-code the type so I'd like to use the second > > variant, but is it possible to optimize it so that it results in a > > single select like the first one? > > > > Thanks for any hints! > > -Mihai > > _______________________________________________ > > Cl-perec-devel mailing list > > Cl-perec-devel at common-lisp.net > > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > > From levente.meszaros at gmail.com Mon Oct 12 08:42:12 2009 From: levente.meszaros at gmail.com (=?ISO-8859-1?Q?Levente_M=E9sz=E1ros?=) Date: Mon, 12 Oct 2009 10:42:12 +0200 Subject: [Cl-perec-devel] Optimization question In-Reply-To: <6e131de2bdfe1c0dcf3292988b328d23@bazon.net> References: <6e131de2bdfe1c0dcf3292988b328d23@bazon.net> Message-ID: I think I wasn't clear enough, obviously you can use `, in place of ' (let ((class-name 'foo)) ;; it's not hardcoded (execute-query (make-query `(select-instances (o) (where (typep o ,class-name))))) Also if you look at the generated SQL it does select prefetched slots too. This code fragment calls the query compiler runtime unless the exact same query is already compiled. In that case it looks up the resulting lambda from the cache. Cheers, levy 2009/10/9 Mihai Bazon : > You hard-coded the type, which is what I want to avoid. ?That works, > but consider the following: > > ? ? ? ?(defvar tmp 'foo) ?;*** the type is in a variable > ? ? ? ?(with-transaction > ? ? ? ? ? (execute-query > ? ? ? ? ? ?(make-query '(select-instances > ? ? ? ? ? ? ? ? ? ? ? ? ?(o) (where (typep o tmp))))))) > > It results in: > > ; BEGIN > ; SELECT _o._oid FROM _foo_ai _o > ; COMMIT > > (so it doesn't select all data, only the OID; the result is a list of > objects, but individual SELECT-s will run for each of them to retrieve > the value of 's when it's needed). > > BTW: I'm setting compiled-query-cache like this: > > ? (let ((prc::*compiled-query-cache* (site-query-cache ,site)) ... > > where site-query-cache is an accessor for the following slot: > > ? (query-cache :accessor site-query-cache > ? ? ? ? ? ? ? ?:initform (prc::make-compiled-query-cache)) > > It seems to work, and definitely improves performance (about 2x > faster). ?Hope it's a clean way... > > Tomorrow I'll try to understand how to use the macro that Attila > suggested--again, sorry for I'm trying to learn too much in too little > time... > > Cheers, > -Mihai > > Levente M?sz?ros wrote: >> I suggest to build a query form dynamically and execute that. Query >> cache will prevent calling the query compiler each time and you can >> build free queries with this. >> >> TEST> (defpclass* foo () >> ? ? ? ? ((s :type boolean))) >> # >> >> TEST> (with-transaction >> ? ? ? ? (make-instance 'foo :s t)) >> >> ; BEGIN >> ; SELECT NEXTVAL('_instance_id') >> ; $1 = 475775 as BIGINT, $2 = TRUE as BOOL >> ; INSERT INTO _foo (_oid, _s) VALUES ($1::BIGINT, $2::BOOL) >> ; COMMIT >> # >> >> TEST> (with-transaction (execute-query (make-query '(select-instances >> (o) (where (typep o 'foo)))))) >> ; BEGIN >> ; SELECT _o._oid, _o._s FROM _foo_ap _o >> ; COMMIT >> (# # # >> ?#) >> >> Be sure to bind this variable high enough: >> >> TEST> hu.dwim.perec::*compiled-query-cache* >> # >> >> levy >> >> -- >> There's no perfectoin >> >> On Fri, Oct 9, 2009 at 3:00 PM, Mihai Bazon wrote: >> > Hi folks, >> > >> > Here are two variants, I'd say equivalent, to select some objects: >> > >> > ? (select-instances (o) (where (typep o 'db-group))) >> > >> > ? (defvar tmp 'db-user) >> > ? (select-instances (o) (where (typep o tmp))) >> > >> > Both work the same, but the first one is better because it results in a >> > single select that fetches the data as well. ?Here's what I see using >> > start-sql-recording: >> > >> > 1st version: >> > >> > ; SELECT _o._oid, _o._edition, _o._name, _o._description FROM _db_group_ap _o >> > >> > 2nd version: >> > >> > ; SELECT _o._oid FROM _db_group_ai _o >> > ; $1 = 69012 as BIGINT >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) >> > ; $1 = 134548 as BIGINT >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) >> > ; $1 = 200084 as BIGINT >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) >> > >> > I presume there's some compile-time magic that happens in case 1 and not >> > in case 2. ?I can't hard-code the type so I'd like to use the second >> > variant, but is it possible to optimize it so that it results in a >> > single select like the first one? >> > >> > Thanks for any hints! >> > -Mihai >> > _______________________________________________ >> > Cl-perec-devel mailing list >> > Cl-perec-devel at common-lisp.net >> > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel >> > -- There's no perfectoin From mihai at bazon.net Mon Oct 12 09:02:35 2009 From: mihai at bazon.net (Mihai Bazon) Date: Mon, 12 Oct 2009 12:02:35 +0300 Subject: [Cl-perec-devel] Optimization question In-Reply-To: References: <6e131de2bdfe1c0dcf3292988b328d23@bazon.net> Message-ID: Ah.. Clear enough now, my bad for not thinking backquote. :-) Thanks! -Mihai Levente M?sz?ros wrote: > I think I wasn't clear enough, obviously you can use `, in place of ' > > (let ((class-name 'foo)) ;; it's not hardcoded > (execute-query (make-query `(select-instances (o) (where (typep o > ,class-name))))) > > Also if you look at the generated SQL it does select prefetched slots > too. This code fragment calls the query compiler runtime unless the > exact same query is already compiled. In that case it looks up the > resulting lambda from the cache. > > Cheers, > levy > > 2009/10/9 Mihai Bazon : > > You hard-coded the type, which is what I want to avoid. ?That works, > > but consider the following: > > > > ? ? ? ?(defvar tmp 'foo) ?;*** the type is in a variable > > ? ? ? ?(with-transaction > > ? ? ? ? ? (execute-query > > ? ? ? ? ? ?(make-query '(select-instances > > ? ? ? ? ? ? ? ? ? ? ? ? ?(o) (where (typep o tmp))))))) > > > > It results in: > > > > ; BEGIN > > ; SELECT _o._oid FROM _foo_ai _o > > ; COMMIT > > > > (so it doesn't select all data, only the OID; the result is a list of > > objects, but individual SELECT-s will run for each of them to retrieve > > the value of 's when it's needed). > > > > BTW: I'm setting compiled-query-cache like this: > > > > ? (let ((prc::*compiled-query-cache* (site-query-cache ,site)) ... > > > > where site-query-cache is an accessor for the following slot: > > > > ? (query-cache :accessor site-query-cache > > ? ? ? ? ? ? ? ?:initform (prc::make-compiled-query-cache)) > > > > It seems to work, and definitely improves performance (about 2x > > faster). ?Hope it's a clean way... > > > > Tomorrow I'll try to understand how to use the macro that Attila > > suggested--again, sorry for I'm trying to learn too much in too little > > time... > > > > Cheers, > > -Mihai > > > > Levente M?sz?ros wrote: > >> I suggest to build a query form dynamically and execute that. Query > >> cache will prevent calling the query compiler each time and you can > >> build free queries with this. > >> > >> TEST> (defpclass* foo () > >> ? ? ? ? ((s :type boolean))) > >> # > >> > >> TEST> (with-transaction > >> ? ? ? ? (make-instance 'foo :s t)) > >> > >> ; BEGIN > >> ; SELECT NEXTVAL('_instance_id') > >> ; $1 = 475775 as BIGINT, $2 = TRUE as BOOL > >> ; INSERT INTO _foo (_oid, _s) VALUES ($1::BIGINT, $2::BOOL) > >> ; COMMIT > >> # > >> > >> TEST> (with-transaction (execute-query (make-query '(select-instances > >> (o) (where (typep o 'foo)))))) > >> ; BEGIN > >> ; SELECT _o._oid, _o._s FROM _foo_ap _o > >> ; COMMIT > >> (# # # > >> ?#) > >> > >> Be sure to bind this variable high enough: > >> > >> TEST> hu.dwim.perec::*compiled-query-cache* > >> # > >> > >> levy > >> > >> -- > >> There's no perfectoin > >> > >> On Fri, Oct 9, 2009 at 3:00 PM, Mihai Bazon wrote: > >> > Hi folks, > >> > > >> > Here are two variants, I'd say equivalent, to select some objects: > >> > > >> > ? (select-instances (o) (where (typep o 'db-group))) > >> > > >> > ? (defvar tmp 'db-user) > >> > ? (select-instances (o) (where (typep o tmp))) > >> > > >> > Both work the same, but the first one is better because it results in a > >> > single select that fetches the data as well. ?Here's what I see using > >> > start-sql-recording: > >> > > >> > 1st version: > >> > > >> > ; SELECT _o._oid, _o._edition, _o._name, _o._description FROM _db_group_ap _o > >> > > >> > 2nd version: > >> > > >> > ; SELECT _o._oid FROM _db_group_ai _o > >> > ; $1 = 69012 as BIGINT > >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > >> > ; $1 = 134548 as BIGINT > >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > >> > ; $1 = 200084 as BIGINT > >> > ; SELECT _edition, _name, _description FROM _db_group_dd WHERE (_oid = $1::BIGINT) > >> > > >> > I presume there's some compile-time magic that happens in case 1 and not > >> > in case 2. ?I can't hard-code the type so I'd like to use the second > >> > variant, but is it possible to optimize it so that it results in a > >> > single select like the first one? > >> > > >> > Thanks for any hints! > >> > -Mihai > >> > _______________________________________________ > >> > Cl-perec-devel mailing list > >> > Cl-perec-devel at common-lisp.net > >> > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > >> > > > > > -- > There's no perfectoin From valeriy.fedotov at gmail.com Mon Oct 12 21:38:45 2009 From: valeriy.fedotov at gmail.com (Valeriy Fedotov) Date: Tue, 13 Oct 2009 01:38:45 +0400 Subject: [Cl-perec-devel] Bug with accessors to boolean field. Message-ID: Hello. I think I have found a bug in cl-perec. The following lines in REPL reproduce it. (My lisp is SBCL 1.0.29, cl-perec and all required libraries are installed via clbuild.) (asdf:oos 'asdf:load-op :cl-perec) (in-package :cl-perec) ;; Then I connect to database, Postgresql in my case. (defpclass* example () ((f1 :type string) (f2 :type boolean))) (with-transaction (make-instance 'example :f1 "123" :f2 t)) (with-transaction (let ((e (select-instance (e example)))) (f1-of e))) ;; Works fine and returns "123" (with-transaction (let ((e (select-instance (e example)))) (f2-of e))) ;; The function F2-OF is undefined. ;; [Condition of type UNDEFINED-FUNCTION] PS. By the way, do you rejected #t and #f convection for true and false? T and NIL work fine for me, but Pinterface's tutorial and tests confused me and I tried get them working. -- ? ?????????, ??????? ???????. From mihai at bazon.net Mon Oct 12 22:17:34 2009 From: mihai at bazon.net (Mihai Bazon) Date: Tue, 13 Oct 2009 01:17:34 +0300 Subject: [Cl-perec-devel] Bug with accessors to boolean field. In-Reply-To: References: Message-ID: The default accessors for boolean fields end in "-p", rather than "-of". So for your example, use (f2-p e). (I just learned this today ;-) You can safely use T and NIL instead of #T and #F; these are reader macros, not sure where they are defined (maybe cl-syntax-sugar) but you need to import them or :use that package... or just define them yourself. I myself prefer sticking with T and NIL. Cheers, -Mihai Valeriy Fedotov wrote: > Hello. > > I think I have found a bug in cl-perec. The following lines in REPL > reproduce it. (My lisp is SBCL 1.0.29, cl-perec and all required > libraries are installed via clbuild.) > > (asdf:oos 'asdf:load-op :cl-perec) > > (in-package :cl-perec) > > ;; Then I connect to database, Postgresql in my case. > > (defpclass* example () > ((f1 :type string) > (f2 :type boolean))) > > (with-transaction > (make-instance 'example :f1 "123" :f2 t)) > > (with-transaction > (let ((e (select-instance (e example)))) > (f1-of e))) > ;; Works fine and returns "123" > > (with-transaction > (let ((e (select-instance (e example)))) > (f2-of e))) > ;; The function F2-OF is undefined. > ;; [Condition of type UNDEFINED-FUNCTION] > > PS. By the way, do you rejected #t and #f convection for true and > false? T and NIL work fine for me, but Pinterface's tutorial and tests > confused me and I tried get them working. > > -- > ? ?????????, ??????? ???????. > > _______________________________________________ > Cl-perec-devel mailing list > Cl-perec-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel From levente.meszaros at gmail.com Tue Oct 13 08:18:01 2009 From: levente.meszaros at gmail.com (=?ISO-8859-1?Q?Levente_M=E9sz=E1ros?=) Date: Tue, 13 Oct 2009 10:18:01 +0200 Subject: [Cl-perec-devel] Bug with accessors to boolean field. In-Reply-To: References: Message-ID: As for the setup of #t and #f and other special syntaxes see the function setup-readtable in configuration.lisp and its use in the asd files. levy ps: The newly refactored code at dwim.hu does this somewhat simpler (and may be simplified even further). On Tue, Oct 13, 2009 at 12:17 AM, Mihai Bazon wrote: > The default accessors for boolean fields end in "-p", rather than "-of". > So for your example, use (f2-p e). ?(I just learned this today ;-) > > You can safely use T and NIL instead of #T and #F; these are reader > macros, not sure where they are defined (maybe cl-syntax-sugar) but you > need to import them or :use that package... or just define them > yourself. ?I myself prefer sticking with T and NIL. > > Cheers, > -Mihai > > Valeriy Fedotov wrote: >> Hello. >> >> I think I have found a bug in cl-perec. The following lines in REPL >> reproduce it. (My lisp is SBCL 1.0.29, cl-perec and all required >> libraries are installed via clbuild.) >> >> (asdf:oos 'asdf:load-op :cl-perec) >> >> (in-package :cl-perec) >> >> ;; Then I connect to database, Postgresql in my case. >> >> (defpclass* example () >> ? ? ? ?((f1 :type string) >> ? ? ? (f2 :type boolean))) >> >> (with-transaction >> ? ? ? ?(make-instance 'example :f1 "123" :f2 t)) >> >> (with-transaction >> ? ? ? ?(let ((e (select-instance (e example)))) >> ? ? ? ?(f1-of e))) >> ;; Works fine and returns "123" >> >> (with-transaction >> ? ? ? ?(let ((e (select-instance (e example)))) >> ? ? ? ?(f2-of e))) >> ;; The function F2-OF is undefined. >> ;; ? ?[Condition of type UNDEFINED-FUNCTION] >> >> PS. By the way, do you rejected #t and #f convection for true and >> false? T and NIL work fine for me, but Pinterface's tutorial and tests >> confused me and I tried get them working. >> >> -- >> ? ?????????, ??????? ???????. >> >> _______________________________________________ >> Cl-perec-devel mailing list >> Cl-perec-devel at common-lisp.net >> http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > _______________________________________________ > Cl-perec-devel mailing list > Cl-perec-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > -- There's no perfectoin From mihai at bazon.net Fri Oct 16 13:50:26 2009 From: mihai at bazon.net (Mihai Bazon) Date: Fri, 16 Oct 2009 16:50:26 +0300 Subject: [Cl-perec-devel] How to select individual fields? Message-ID: <16cf6363090e571a43afb14bbfa09fdd@bazon.net> Hi, I'm trying to write a query that selects only a few fields. Example that works: (select ((create-time-of o)) (from (o db-template))) ; SELECT _o._create_time FROM _db_template_ap _o Adding one more field though results in a SELECT that covers all fields: (select ((create-time-of o) (modify-time-of o)) (from (o db-template))) ; SELECT _o._oid, _o._edition, _o._create_time, _o._modify_time, _o._name, _o._body_type, _o._edited_body, _o._processed_body, _o._parent_oid FROM _db_template_ap _o Is there any way to fetch more than one field, but not all, in a single query? Thanks, -Mihai From tomi.borbely at gmail.com Mon Oct 19 13:44:00 2009 From: tomi.borbely at gmail.com (=?ISO-8859-1?Q?Borb=E9ly_Tam=E1s_?=) Date: Mon, 19 Oct 2009 15:44:00 +0200 Subject: [Cl-perec-devel] How to select individual fields? In-Reply-To: <16cf6363090e571a43afb14bbfa09fdd@bazon.net> References: <16cf6363090e571a43afb14bbfa09fdd@bazon.net> Message-ID: <53c1332f0910190644n2772c1eft730285101455d8e8@mail.gmail.com> Hi, It was really suboptimal. This patch hopefully fix it: Mon Oct 19 15:33:08 CEST 2009 tomi.borbely at gmail.com * optimization of queries that select slot values only regards, Tomi 2009/10/16 Mihai Bazon > Hi, > > I'm trying to write a query that selects only a few fields. > > Example that works: > > (select ((create-time-of o)) > (from (o db-template))) > > ; SELECT _o._create_time FROM _db_template_ap _o > > Adding one more field though results in a SELECT that covers all > fields: > > (select ((create-time-of o) (modify-time-of o)) > (from (o db-template))) > > ; SELECT _o._oid, _o._edition, _o._create_time, _o._modify_time, > _o._name, _o._body_type, _o._edited_body, _o._processed_body, > _o._parent_oid FROM _db_template_ap _o > > Is there any way to fetch more than one field, but not all, in a single > query? > > Thanks, > -Mihai > _______________________________________________ > Cl-perec-devel mailing list > Cl-perec-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-perec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: